AAO DRAMA/DRAMA2 C++ Interface
Public Member Functions | List of all members
drama::gitarg::Enum< LookupClass, EnumType > Class Template Reference

Detailed Description

template<typename LookupClass, typename EnumType>
class drama::gitarg::Enum< LookupClass, EnumType >

A class which reads Enumerated values from a SDS argument structures.

This is an template class used for cases where we want to fetch a STRING action argument which must then be converted to an enum type. That is, the string is a representation of an enumerated value.

drama::gitarg::Enum is a template class. Two template arguments are required - "LookupClass" and "EnumType". The former must be a sub-class of drama::gitarg::EnumLookupClass. The later is a normally simple enum type - it must be possible to cast this class from an integer and cast back to an integer from this class.

See also
GitArgGetS()
Template Parameters
LookupClassA sub-class of drama::gitarg::EnumLookupClass with GetMaxValue() and GetStringArray() implemented.
EnumTypeThe underlying enumerated type. Must be possible to cast to and from an int. Must have values for 0 through to LookupClass->GetMaxValue()+1 inclusive (no gaps), where GetMaxValues()+1 is used to indicate an invalid value.

#include "gitarg.hh"

Public Member Functions

 Enum ()
 Default contructor for the object. More...
 
 Enum (EnumType InitialValue)
 Constructor with initial value supplied. More...
 
 Enum (const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::Upper|Flags::Abbrev|Flags::KeepErr)
 Constructor which contructs the value from an item in an SDS structure. More...
 
virtual ~Enum ()
 Destructor. More...
 
void Get (const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::Upper|Flags::Abbrev|Flags::KeepErr)
 Get the value of the object from an SDS structure. More...
 
 operator EnumType () const
 Return the underlying value of this object. More...
 
 operator std::string () const
 Return the underlying value of this object as a string. More...
 

Constructor & Destructor Documentation

template<typename LookupClass, typename EnumType>
drama::gitarg::Enum< LookupClass, EnumType >::Enum ( )
inline

Default contructor for the object.

This will set the value of the object to be the invalid value, obtained by setting the value to the lookup class's GetMaxValue() value + 1.

template<typename LookupClass, typename EnumType>
drama::gitarg::Enum< LookupClass, EnumType >::Enum ( EnumType  InitialValue)
inline

Constructor with initial value supplied.

The initial value must be one of the values in the enum type.

Parameters
InitialValueThe initial value for the objects.
template<typename LookupClass, typename EnumType>
drama::gitarg::Enum< LookupClass, EnumType >::Enum ( const sds::Id Id,
const std::string &  Name = "Argument1",
const int  Position = 1,
const std::string &  Default = "",
const Flags  flags = Flags::Upper|Flags::Abbrev|Flags::KeepErr 
)
inline

Constructor which contructs the value from an item in an SDS structure.

The value is fetched from the named item (arg #2) within the SDS structure specified. or the Position (constructor arg #3) item in the structure if the item named does not exist.

Parameters
IdThe SDS structure.
NameThe name of the item within the structure.
PositionIf the item does not exist by the name, then presume this position.
DefaultThe default value. If not specified, the first enum value is used.
flagsWhich GIT Flags to apply. If you specify KeepErr, then an exception is thrown if the value in the SDS structure is invalid. If you don't specify KeepErr and and the SDS structure is invalid, then the enum value is set to the Invalid value.
template<typename LookupClass, typename EnumType>
virtual drama::gitarg::Enum< LookupClass, EnumType >::~Enum ( )
inlinevirtual

Destructor.

Member Function Documentation

template<typename LookupClass, typename EnumType>
void drama::gitarg::Enum< LookupClass, EnumType >::Get ( const sds::Id Id,
const std::string &  Name = "Argument1",
const int  Position = 1,
const std::string &  Default = "",
const Flags  flags = Flags::Upper|Flags::Abbrev|Flags::KeepErr 
)
inline

Get the value of the object from an SDS structure.

The value is fetch from the named item (arg #2) within the SDS structure specified. or the Position (constructor arg #3) item in the structure if the item named does not exist.

Parameters
IdThe SDS structure.
NameThe name of the item within the structure.
PositionIf the item does not exist by the name, then presume this position.
DefaultThe default value. If not specified use 0 (first enum val)
flagsWhich GIT Flags to apply. If you specify KeepErr, then an exception is thrown if the value in the SDS structure is invalid. If you don't specify KeepErr and and the SDS structure does not contain a value item, then the enum value is set to the Invalid value.

Referenced by drama::gitarg::Enum< ResetEnumLookup, ResetEnum >::Enum().

template<typename LookupClass, typename EnumType>
drama::gitarg::Enum< LookupClass, EnumType >::operator EnumType ( ) const
inline

Return the underlying value of this object.

template<typename LookupClass, typename EnumType>
drama::gitarg::Enum< LookupClass, EnumType >::operator std::string ( ) const
inline

Return the underlying value of this object as a string.


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

Click here for the DRAMA home page and here for the AAO home page.

For more information, contact tjf@aao.gov.au 

Generated on Mon Feb 22 2016 15:57:53 for AAO DRAMA/DRAMA2 C++ Interface by doxygen 1.8.10