Classes | Public Member Functions

Barry::EnumConstants Class Reference
[GenericFieldHandles]

This is the base class for the hierarchy of classes to define enum record members. More...

#include <record.h>

Inheritance diagram for Barry::EnumConstants:
Inheritance graph
[legend]
Collaboration diagram for Barry::EnumConstants:
Collaboration graph
[legend]

List of all members.

Classes

struct  EnumConstant
 This defines one of the enum constants being defined. More...

Public Member Functions

void AddConstant (const char *name, const std::string &display, int val)
 Adds a constant definition to the list.
const EnumConstantList & GetConstantList () const
 Returns a vector of EnumConstant objects, describing all enum constants valid for this enum field.
const EnumConstantGetConstant (int value) const
 Returns the EnumConstant for the given value.
const char * GetName (int value) const
 Returns the constant name (C++ name) based on the given value.
const std::string & GetDisplayName (int value) const
 Returns the display name based on the given value.
bool IsConstantValid (int value) const
 Returns true if the value matches one of the constants in the list.

Detailed Description

This is the base class for the hierarchy of classes to define enum record members.

This is the base class, which contains the common code for creating and defining a list of enum constants for a given enum field. The next derived class is EnumFieldBase<RecordT>, which defines the virtual API for talking to a given enum field in a given record. The next derived class is EnumField<RecordT, EnumT>, which implements the pointer-to-member and virtual API for a given enum type in a given record class.

For example, the Bookmark record class has the following enum field:

   	enum BrowserIdentityType
   	{
   		IdentityAuto = 0,
   		IdentityBlackBerry,
   		IdentityFireFox,
   		IdentityInternetExplorer,
   		IdentityUnknown
   	};
   	BrowserIdentityType BrowserIdentity;
    

The EnumConstants class will hold a vector of EnumConstant structs defining each of the identity constants: Auto, BlackBerry, FireFox, InternetExplorer, and Unknown.

The derived class EnumFieldBase<Bookmark> will define two additional pure virtual API calls: GetValue(const Bookmark&) and SetValue(Bookmark&, int).

Finally, the derived class EnumField<Bookmark,Bookmark::BrowserIdentityType> will implement the virtual API, and contain a pointer-to-member to the Bookmark::BrowserIdentity member field.

The FieldHandle<Bookmark> class will hold a pointer to EnumFieldBase<Bookmark>, which can hold a pointer to a specific EnumField<> object, one object for each of Bookmark's enum types, of which there are currently 3.

Definition at line 637 of file record.h.


Member Function Documentation

void Barry::EnumConstants::AddConstant ( const char *  name,
const std::string &  display,
int  val 
)

Adds a constant definition to the list.

Definition at line 572 of file record.cc.

const EnumConstants::EnumConstant & Barry::EnumConstants::GetConstant ( int  value  )  const

Returns the EnumConstant for the given value.

Throws std::logic_error if not found.

Definition at line 579 of file record.cc.

Referenced by GetDisplayName(), and GetName().

Here is the caller graph for this function:

const EnumConstantList& Barry::EnumConstants::GetConstantList (  )  const [inline]

Returns a vector of EnumConstant objects, describing all enum constants valid for this enum field.

Definition at line 673 of file record.h.

const std::string & Barry::EnumConstants::GetDisplayName ( int  value  )  const

Returns the display name based on the given value.

Throws std::logic_error if not found.

Definition at line 598 of file record.cc.

References GetConstant().

Here is the call graph for this function:

const char * Barry::EnumConstants::GetName ( int  value  )  const

Returns the constant name (C++ name) based on the given value.

Throws std::logic_error if not found.

Definition at line 593 of file record.cc.

References GetConstant().

Here is the call graph for this function:

bool Barry::EnumConstants::IsConstantValid ( int  value  )  const

Returns true if the value matches one of the constants in the list.

Definition at line 603 of file record.cc.

Referenced by Barry::EnumField< RecordT, EnumT >::SetValue().

Here is the caller graph for this function:


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