CDPEnum Class
The CDP Enum is a class to hold enums as string/value pairs. More...
Header: | #include <CDPSystem/Base/CDPEnum.h> |
Inherits: | CDP::StudioAPI::CDPNode |
Public Functions
CDPEnum(const std::string &name) | |
CDPEnum(const std::string &name, const std::vector<CDPEnumPair> &enums) | |
~CDPEnum() | |
void | AddEnumToList(const std::string &name, int value) |
void | Set(const std::vector<CDPEnumPair> &enums) |
operator const std::string &() const | |
operator int() const | |
bool | operator!=(const int val) |
int | operator=(const int rhs) |
const std::string & | operator=(const std::string &val) |
bool | operator==(const int val) |
bool | operator==(const std::string &val) |
Reimplemented Public Functions
virtual void | FillNodeChildren(CDP::StudioAPI::NodeStream &serializer) const override |
virtual const std::string | GetNodeName() const override |
virtual CDP::StudioAPI::CDPNodeType | GetNodeType() const override |
virtual std::string | GetNodeTypeName() const override |
virtual CDP::StudioAPI::CDPValueType | GetNodeValueType() const override |
virtual CDP::StudioAPI::CDPVariantValue | GetVariantValue() const override |
virtual void | SetVariantValue(const CDP::StudioAPI::CDPVariantValue &newValue) override |
- 26 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode
Additional Inherited Members
- 1 protected function inherited from CDP::StudioAPI::CDPNode
Detailed Description
The CDP Enum is a class to hold enums as string/value pairs.
Example:
CDPEnum enum("StateEnum"); enum.Set({{"e_Stopped",e_Stopped}, {"e_Running",e_Running}, {"e_Error",e_Error}}); enum = e_Stopped; // or you can use enum = "e_Stopped", but that is marginally slower; enum = e_Halted; // this won't change the enum value, as that is not a defined enum! assert(enum==e_Stopped); enum.AddEnumToList("e_Halted",(int)e_Halted); enum = e_Halted; // This changes the enum value to e_Halted assert(enum==e_Halted); // now this works
Member Function Documentation
CDPEnum::CDPEnum(const std::string &name)
Constructs a CDPEnum.
Parameter name should give a unique name to this CDPNode.
CDPEnum::CDPEnum(const std::string &name, const std::vector<CDPEnumPair> &enums)
Constructs a CDPEnum from a list of entries which set all possible enum values.
Parameter name should give a unique name to this CDPNode.
CDPEnum::~CDPEnum()
Destructs the instance.
void CDPEnum::AddEnumToList(const std::string &name, int value)
Adds an enum to the list of enums available in this CDPEnum.
Parameter name will be the string represenation of this enum value. Parameter value will be the numeric value of this enum.
[override virtual]
void CDPEnum::FillNodeChildren(CDP::StudioAPI::NodeStream &serializer) const
Reimplemented from CDPNode::FillNodeChildren().
[override virtual]
const std::string CDPEnum::GetNodeName() const
Reimplemented from ICDPNode::GetNodeName().
[override virtual]
CDP::StudioAPI::CDPNodeType CDPEnum::GetNodeType() const
Reimplemented from ICDPNode::GetNodeType().
[override virtual]
std::string CDPEnum::GetNodeTypeName() const
Reimplemented from ICDPNode::GetNodeTypeName().
[override virtual]
CDP::StudioAPI::CDPValueType CDPEnum::GetNodeValueType() const
Reimplemented from ICDPNode::GetNodeValueType().
[override virtual]
CDP::StudioAPI::CDPVariantValue CDPEnum::GetVariantValue() const
Reimplemented from ICDPNode::GetVariantValue().
void CDPEnum::Set(const std::vector<CDPEnumPair> &enums)
Appends a list of enums.
Could be specified like this: { {"A", 1}, {"B", 2} }
[override virtual]
void CDPEnum::SetVariantValue(const CDP::StudioAPI::CDPVariantValue &newValue)
Reimplemented from CDPNode::SetVariantValue().
CDPEnum::operator const std::string &() const
Returns the value of this object as a string.
CDPEnum::operator int() const
Returns the value of this object as an integer.
bool CDPEnum::operator!=(const int val)
Inequality operator for type int.
int CDPEnum::operator=(const int rhs)
Assignment operator from an integer.
const std::string &CDPEnum::operator=(const std::string &val)
Assignment operator from const std::string&.
bool CDPEnum::operator==(const int val)
Comparison operator with an integer.
bool CDPEnum::operator==(const std::string &val)
Comparison operator with const std::string&.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.