ICG 2
Electric Boogaloo
Public Member Functions | Static Public Attributes | List of all members
EnumDataType Class Reference

Enum represents an Enumerated data type. More...

#include <EnumDataType.hpp>

Inheritance diagram for EnumDataType:
DataType

Public Member Functions

 EnumDataType (EnumDictionary *enumDictionary, std::string name, size_t sizeof_element)
 Constructor for an Enumerated type object. More...
 
 EnumDataType (const EnumDataType &original)=delete
 
 ~EnumDataType ()
 
EnumDataTypeoperator= (EnumDataType rhs)=delete
 
bool validate (DataTypeInator *dataTypeInator=NULL) override
 Verify that all of the types that are named by this DataType or subordinate DataTypes are resolvable to actual DataTypes in the TypeDictionary. More...
 
bool isValid () const override
 Determine whether this type has already been successfully validated. More...
 
size_t getSize () const override
 
void * createInstance (unsigned int num) const override
 Create one or more instances of this type. More...
 
void deleteInstance (void *address) const override
 Delete this instance. More...
 
std::string toString () const override
 
std::string getTypeSpecName () const override
 
bool accept (DataTypeVisitor *visitor) const override
 
void clearValue (void *address) const
 Set the instance of this type at the given address to 0. More...
 
bool assignValue (void *address, int value) const
 Assign the value to the instance of this data member. More...
 
int getValue (void *address) const
 Get the Value of an instance of this type with the given address. More...
 
void addEnumerator (std::string val_name, int value)
 Add a name-value pair to this enum data type. More...
 
std::string lookupEnumeratorName (int value) const
 Get the string name that corresponds to the integer for this type. More...
 
bool containsValue (int value) const
 Determine if this enum type has something defined to this value. More...
 
- Public Member Functions inherited from DataType
virtual ~DataType ()
 
virtual std::string makeDeclaration (std::string declarator) const
 

Static Public Attributes

static const std::string invalid_str
 

Detailed Description

Enum represents an Enumerated data type.

Note
since the underlying type can vary in size, it would possibly be cleaner to implement this in a similar way to the Primitive/SpecifiedPrimititive<T> hierarchy. However, I think since there are only 3 possible sizes, maybe this is ok.

Constructor & Destructor Documentation

◆ EnumDataType() [1/2]

EnumDataType::EnumDataType ( EnumDictionary enumDictionary,
std::string  name,
size_t  sizeof_element 
)

Constructor for an Enumerated type object.

Parameters
enumDictionaryglobal enum value dictionary
namename of type
sizeof_elementsize, in bytes, of this type

◆ EnumDataType() [2/2]

EnumDataType::EnumDataType ( const EnumDataType original)
delete

◆ ~EnumDataType()

EnumDataType::~EnumDataType ( )

Member Function Documentation

◆ accept()

bool EnumDataType::accept ( DataTypeVisitor visitor) const
overridevirtual

Implements DataType.

◆ addEnumerator()

void EnumDataType::addEnumerator ( std::string  val_name,
int  value 
)

Add a name-value pair to this enum data type.

Parameters
val_nameliteral name of this enum member
valueinteger value associated

◆ assignValue()

bool EnumDataType::assignValue ( void *  address,
int  value 
) const

Assign the value to the instance of this data member.

Parameters
addressAddress to assign to
valueinteger value to assign. Must be a pre-defined value for this type.

◆ clearValue()

void EnumDataType::clearValue ( void *  address) const

Set the instance of this type at the given address to 0.

Parameters
addressaddress of instance

◆ containsValue()

bool EnumDataType::containsValue ( int  value) const

Determine if this enum type has something defined to this value.

Parameters
valueinteger value to find
Returns
true if found, false otherwise

◆ createInstance()

void * EnumDataType::createInstance ( unsigned int  n) const
overridevirtual

Create one or more instances of this type.

Parameters
nnumber to create
Returns
void* address of the beginnning of the allocation

Implements DataType.

◆ deleteInstance()

void EnumDataType::deleteInstance ( void *  address) const
overridevirtual

Delete this instance.

Parameters
addressof instance to delete
Note
Is this compatible with the createInstance?

Implements DataType.

◆ getSize()

size_t EnumDataType::getSize ( ) const
overridevirtual
Returns
The size (in bytes) of an instance of the EnumDataType.

Implements DataType.

◆ getTypeSpecName()

std::string EnumDataType::getTypeSpecName ( ) const
overridevirtual

Get the name of the enumeration type.

Implements DataType.

◆ getValue()

int EnumDataType::getValue ( void *  address) const

Get the Value of an instance of this type with the given address.

Parameters
addressAddress to pull the value from
Returns
int numerical value of the enum instance

◆ isValid()

bool EnumDataType::isValid ( ) const
overridevirtual

Determine whether this type has already been successfully validated.

Returns
true if validated, false otherwise

Implements DataType.

◆ lookupEnumeratorName()

std::string EnumDataType::lookupEnumeratorName ( int  value) const

Get the string name that corresponds to the integer for this type.

Parameters
valueinteger value to find
Returns
std::string name of this value for this type, or empty string if value is not named in this enum

◆ operator=()

EnumDataType& EnumDataType::operator= ( EnumDataType  rhs)
delete

◆ toString()

std::string EnumDataType::toString ( ) const
overridevirtual

Generate a definition of this DataType.

Reimplemented from DataType.

◆ validate()

bool EnumDataType::validate ( DataTypeInator dataTypeInator = NULL)
overridevirtual

Verify that all of the types that are named by this DataType or subordinate DataTypes are resolvable to actual DataTypes in the TypeDictionary.

Parameters
dataTypeInator- type resolver machine
Returns
true if successful, false otherwise

Implements DataType.

Member Data Documentation

◆ invalid_str

const std::string EnumDataType::invalid_str
static

The documentation for this class was generated from the following files: