InFact
Interpreter and factory for easily creating C++ objects at run-time
|
A container for all the member initializers for a particular Factory-constructible instance. More...
#include <factory.h>
Public Types | |
typedef unordered_map< string, MemberInitializer * > ::const_iterator | const_iterator |
Forward the const_iterator typedef of the internal data structure, to make code compact and readable. More... | |
typedef unordered_map< string, MemberInitializer * > ::iterator | iterator |
Forward the iterator typedef of the internal data structure, to make code compact and readable. More... | |
Public Member Functions | |
Initializers () | |
Constructs a new instance. More... | |
virtual | ~Initializers () |
Destroys this instance. More... | |
template<typename T > | |
void | Add (const string &name, T *member, bool required=false) |
This method is the raison d'etre of this class: a method to make it easy to add all supported types of members of a class to be initialized upon construction by its Factory. More... | |
const_iterator | begin () const |
Returns a const iterator pointing to the beginning of the map from member names to pointers to TypedMemberInitializer instances. More... | |
const_iterator | end () const |
Returns a const iterator pointing to the end of the map from member names to pointers to TypedMemberInitializer instances. More... | |
iterator | begin () |
Returns an iterator pointing to the beginning of the map from member names to pointers to TypedMemberInitializer instances. More... | |
iterator | end () |
Returns an iterator pointing to the end of the map from member names to pointers to TypedMemberInitializer instances. More... | |
const_iterator | find (const string &name) const |
Returns a const_iterator pointing to the MemberInitializer associated with the specified name, or else end if no such TypedMemberInitializer exists. More... | |
iterator | find (const string &name) |
Returns an iterator pointing to the MemberInitializer associated with the specified name, or else end if no such TypedMemberInitializer exists. More... | |
A container for all the member initializers for a particular Factory-constructible instance.
This class provides an easy, consistent syntax for Factory-constructible classes to specify which members they want/need initialized by the Factory based on the specification string.
typedef unordered_map<string, MemberInitializer *>::const_iterator infact::Initializers::const_iterator |
typedef unordered_map<string, MemberInitializer *>::iterator infact::Initializers::iterator |
|
inline |
|
inlinevirtual |
|
inline |
This method is the raison d'etre of this class: a method to make it easy to add all supported types of members of a class to be initialized upon construction by its Factory.
name | the name of the member to be initialized (as it should appear in the initialization spec string; note that this string does not have to be identical to the actual member name in the C++ class definition, but the convention is to make it identical but without an underscore character) |
member | a pointer to the class instance's member that is to be initialized based on tokens in a spec string parsed by the Factory::CreateOrDie method |
required | whether this member must be specified in a spec string |
|
inline |
Returns a const iterator pointing to the beginning of the map from member names to pointers to TypedMemberInitializer instances.
|
inline |
Returns an iterator pointing to the beginning of the map from member names to pointers to TypedMemberInitializer instances.
|
inline |
Returns a const iterator pointing to the end of the map from member names to pointers to TypedMemberInitializer instances.
|
inline |
Returns an iterator pointing to the end of the map from member names to pointers to TypedMemberInitializer instances.
|
inline |
Returns a const_iterator
pointing to the MemberInitializer associated with the specified name, or else end if no such TypedMemberInitializer exists.
|
inline |
Returns an iterator
pointing to the MemberInitializer associated with the specified name, or else end if no such TypedMemberInitializer exists.