Enumerated attributes with same name
|
|
---|---|
Dear all, a simple question on enumerated attributes. Since it is not possible to add new states other than the predefined ones (14 states) (i.e. see this post) I would like to use enum attributes to define a state parameter with "unconventional" name (unfortunately I must adopt such names without re-mapping to the TANGO predefined states). My question is: is it possible to have two or more enum attributes within a device server having the same labels? For example: stateParam1 {OK,DEGRADED,OFFLINE} stateParam2 {OK,DEGRADED} The compiler complains a label redeclaration. Do you have suggestions? Cheers, Simone
****************************************************************
Simone Riggi INAF, Osservatorio Astrofisico di Catania Via S. Sofia 78 95123, Catania - Italy phone: +39 095 7332 extension 282 e-mail: simone.riggi@gmail.com, sriggi@oact.inaf.it skype: simone.riggi **************************************************************** |
|
|
---|---|
Hi Simone, Because you are talking about compiler pb, I assume your Tango class is C++. If you use the C++ 11 way of enum declaration, you can have the same label several times.
Then use enum label like FirstEnum::FIRST or SecondEnum::FIRST Hoping this help Emmanuel |
|
|
---|---|
Dear Emmanuel, thanks a lot. It works. Pogo regenerates that piece of code every time, but the rest is fine. Cheers, Simone
****************************************************************
Simone Riggi INAF, Osservatorio Astrofisico di Catania Via S. Sofia 78 95123, Catania - Italy phone: +39 095 7332 extension 282 e-mail: simone.riggi@gmail.com, sriggi@oact.inaf.it skype: simone.riggi **************************************************************** |
|
|
---|---|
Dear Manu, after long time, I forgot to add to the previous question that, as suggested in the User Guide examples (pag. 163), I needed to add a ": short" in your enum class definition:
otherwise I get this error while reading the attribute: Invalid enumeration type. Supported types are C++11 scoped enum with short as underlying data type or old enum Thanks again, Simone
****************************************************************
Simone Riggi INAF, Osservatorio Astrofisico di Catania Via S. Sofia 78 95123, Catania - Italy phone: +39 095 7332 extension 282 e-mail: simone.riggi@gmail.com, sriggi@oact.inaf.it skype: simone.riggi **************************************************************** |