{"action":"created","issue":{"url":"https://api.github.com/repos/openframeworks/openFrameworks/issues/4966","repository_url":"https://api.github.com/repos/openframeworks/openFrameworks","labels_url":"https://api.github.com/repos/openframeworks/openFrameworks/issues/4966/labels{/name}","comments_url":"https://api.github.com/repos/openframeworks/openFrameworks/issues/4966/comments","events_url":"https://api.github.com/repos/openframeworks/openFrameworks/issues/4966/events","html_url":"https://github.com/openframeworks/openFrameworks/issues/4966","id":138110400,"number":4966,"title":"Feature : Sugar for ofParameterGroup list initialization","user":{"login":"elliotwoods","id":328294,"avatar_url":"https://avatars.githubusercontent.com/u/328294?v=3","gravatar_id":"","url":"https://api.github.com/users/elliotwoods","html_url":"https://github.com/elliotwoods","followers_url":"https://api.github.com/users/elliotwoods/followers","following_url":"https://api.github.com/users/elliotwoods/following{/other_user}","gists_url":"https://api.github.com/users/elliotwoods/gists{/gist_id}","starred_url":"https://api.github.com/users/elliotwoods/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elliotwoods/subscriptions","organizations_url":"https://api.github.com/users/elliotwoods/orgs","repos_url":"https://api.github.com/users/elliotwoods/repos","events_url":"https://api.github.com/users/elliotwoods/events{/privacy}","received_events_url":"https://api.github.com/users/elliotwoods/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-03-03T08:26:42Z","updated_at":"2016-03-26T12:28:53Z","closed_at":null,"body":"hey, i'm just trying something out here\r\n\r\nif we have a class like\r\n```c++\r\nclass ParameterGroup : public ofParameterGroup {\r\npublic:\r\n\ttypedef initializer_list<ofAbstractParameter *> InitializerList;\r\n\tParameterGroup(const InitializerList & parameters) {\r\n\t\tfor(auto parameter : parameters) {\r\n\t\t\tthis->add(*parameter);\r\n\t\t\tdelete parameter;\r\n\t\t}\r\n\t}\r\n\t\r\n\tParameterGroup(const string & name, const InitializerList parameters)\r\n\t: ParameterGroup(parameters) {\r\n\t\tthis->setName(name);\r\n\t}\r\n};\r\n```\r\n\r\nThen we can write code like:\r\n```c++\r\n\tParameterGroup parameters = {\r\n\t\tnew ofParameter<int>(\"My int\", 0),\r\n\t\tnew ofParameter<string>(\"My string\", \"\"),\r\n\t\tnew ParameterGroup(\"Subgroup\", {\r\n\t\t\tnew ofParameter<int>(\"Deeper int\", 0),\r\n\t\t\tnew ParameterGroup(\"Subgroup 2\", {\r\n\t\t\t\tnew ofParameter<int>(\"Even deeper int\", 0),\r\n\t\t\t})\r\n\t\t})\r\n\t};\r\n```\r\n\r\nwhich will evaluate to a tree of parameters. And since C++11, we can just write that directly into the header file. neat huh? \r\n\r\nthis syntax isn't ideal of course. Much better would be something like\r\n\r\n```c++\r\n\tParameterGroup parameters = {\r\n\t\t\r\n\t\tofParameter<int>(\"My int\", 0),\r\n\t\tofParameter<string>(\"My string\", \"\"),\r\n\t\t\r\n\t\t\"Subgroup\" : {\r\n\t\t\t\r\n\t\t\tofParameter<int>(\"Deeper int\", 0),\r\n\t\t\t\r\n\t\t\t{\r\n\t\t\t\tofParameter<int>(\"Even deeper int\", 0),\r\n\t\t\t\t\r\n\t\t\t},\r\n\t\t\t\r\n\t\t},\r\n\t};\r\n```\r\n(note that `initializer_list` doesn't support `&` or `&&` so this would mean having a temporary wrapper type constructed on the abstract reference)\r\n\r\nOr even more sugary is also possible! Especially if there's a way to create reference instances to the individual parameters which can accessed with code completion.\r\n\r\nI mostly thought of this after seeing the new json libraries which have great syntactic sugar, e.g.:\r\n\r\n```c++\r\n//jsoncons\r\n   json book4 = json::parse(R\"(\r\n    {\r\n        \"category\" : \"Fiction\",\r\n        \"title\" : \"Pulp\",\r\n        \"author\" : \"Charles Bukowski\",\r\n        \"date\" : \"2004-07-08\",\r\n        \"price\" : 22.48,\r\n        \"isbn\" : \"1852272007\"  \r\n    }\r\n    )\");\r\n```  \r\n\r\n```c++\r\n//jeayeson (C++14)\r\njson_value val // json_value can be any json type; here, it's a json_map\r\n{\r\n  { \"hello\", \"world\" }, // nested pairs represent key/value\r\n  {\r\n    \"arr\",\r\n    { 1.1, 2.2, 3.3 } // arrays are easy\r\n  },\r\n  {\r\n    \"person\",\r\n    {\r\n      { \"name\", \"Tom\" },\r\n      { \"age\", 36 },\r\n      { \"weapon\", nullptr } // can also use json_null\r\n    }\r\n  }\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/openframeworks/openFrameworks/issues/comments/201800073","html_url":"https://github.com/openframeworks/openFrameworks/issues/4966#issuecomment-201800073","issue_url":"https://api.github.com/repos/openframeworks/openFrameworks/issues/4966","id":201800073,"user":{"login":"arturoc","id":48240,"avatar_url":"https://avatars.githubusercontent.com/u/48240?v=3","gravatar_id":"","url":"https://api.github.com/users/arturoc","html_url":"https://github.com/arturoc","followers_url":"https://api.github.com/users/arturoc/followers","following_url":"https://api.github.com/users/arturoc/following{/other_user}","gists_url":"https://api.github.com/users/arturoc/gists{/gist_id}","starred_url":"https://api.github.com/users/arturoc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arturoc/subscriptions","organizations_url":"https://api.github.com/users/arturoc/orgs","repos_url":"https://api.github.com/users/arturoc/repos","events_url":"https://api.github.com/users/arturoc/events{/privacy}","received_events_url":"https://api.github.com/users/arturoc/received_events","type":"User","site_admin":false},"created_at":"2016-03-26T12:28:53Z","updated_at":"2016-03-26T12:28:53Z","body":"you could store the parameters in the parameter group and access them by name if you want but the syntax is much nicer if you don't so yes most of the time ofParameterGroup is just a way of grouping the parameters by category.\r\n\r\nIf you do so in the headers and also initialize the parameters there, it makes for a nice reference of the parameters of each class:\r\n\r\n```\r\nofParameter<float> width{\"width\", 10, 0, 100};\r\nofParameter<float> height{\"height\", 10, 0, 100};\r\nofParameterGroup size{\r\n    \"size\",\r\n   width,\r\n   height,\r\n};\r\n\r\nofParameter<float> acc{\"acceleration\", 0, 0, 100};\r\nofParameter<float> vel{\"velocity\", 0, 0, 100};\r\nofParameterGroup movement{\r\n    \"movement\",\r\n   acc,\r\n   vel,\r\n};\r\n```"}}