PLearn 0.1
|
#include <ObjectGenerator.h>
Public Member Functions | |
ObjectGenerator () | |
Default constructor. | |
virtual PP< Object > | generateNextObject ()=0 |
This will generate the next object in the list of all options MUST be define by a subclass. | |
virtual TVec< PP< Object > > | generateAllObjects () |
This will generate a list of all possible Objects. | |
virtual void | build () |
simply calls inherited::build() then build_() | |
virtual void | forget () |
virtual ObjectGenerator * | deepCopy (CopiesMap &copies) const |
Static Public Member Functions | |
static string | _classname_ () |
Declares name and deepCopy methods. | |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
Public Attributes | |
PP< Object > | template_object |
The template Object from which we will generate other Objects. | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declare options (data fields) for the class. | |
Protected Attributes | |
bool | generation_began |
Did we begin to generate new Objects??? | |
Private Types | |
typedef Object | inherited |
Private Member Functions | |
void | build_ () |
Object-specific post-constructor. |
Definition at line 47 of file ObjectGenerator.h.
typedef Object PLearn::ObjectGenerator::inherited [private] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::OracleObjectGenerator.
Definition at line 50 of file ObjectGenerator.h.
PLearn::ObjectGenerator::ObjectGenerator | ( | ) |
string PLearn::ObjectGenerator::_classname_ | ( | ) | [static] |
Declares name and deepCopy methods.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::OracleObjectGenerator.
Definition at line 46 of file ObjectGenerator.cc.
OptionList & PLearn::ObjectGenerator::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::OracleObjectGenerator.
Definition at line 46 of file ObjectGenerator.cc.
RemoteMethodMap & PLearn::ObjectGenerator::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::OracleObjectGenerator.
Definition at line 46 of file ObjectGenerator.cc.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::OracleObjectGenerator.
Definition at line 46 of file ObjectGenerator.cc.
StaticInitializer ObjectGenerator::_static_initializer_ & PLearn::ObjectGenerator::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::OracleObjectGenerator.
Definition at line 46 of file ObjectGenerator.cc.
void PLearn::ObjectGenerator::build | ( | ) | [virtual] |
simply calls inherited::build() then build_()
Reimplemented from PLearn::Object.
Reimplemented in PLearn::OracleObjectGenerator.
Definition at line 57 of file ObjectGenerator.cc.
References PLearn::Object::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::ObjectGenerator::build_ | ( | ) | [private] |
Object-specific post-constructor.
This method should be redefined in subclasses and do the actual building of the object according to previously set option fields. Constructors can just set option fields, and then call build_. This method is NOT virtual, and will typically be called only from three places: a constructor, the public virtual build()
method, and possibly the public virtual read method (which calls its parent's read). build_()
can assume that its parent's build_()
has already been called.
Reimplemented from PLearn::Object.
Reimplemented in PLearn::OracleObjectGenerator.
Definition at line 51 of file ObjectGenerator.cc.
References PLearn::PP< T >::isNull(), PLERROR, and template_object.
Referenced by build().
{ if (template_object.isNull()) PLERROR("An ObjectGenerator MUST contain a template Object"); }
void PLearn::ObjectGenerator::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declare options (data fields) for the class.
Redefine this in subclasses: call declareOption
(...) for each option, and then call inherited::declareOptions(options)
. Please call the inherited
method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).
static void MyDerivedClass::declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "The size of the input; it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "The learned model weights"); inherited::declareOptions(ol); }
ol | List of options that is progressively being constructed for the current class. |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::OracleObjectGenerator.
Definition at line 68 of file ObjectGenerator.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::Object::declareOptions(), and template_object.
{ declareOption(ol, "template_object", &ObjectGenerator::template_object, OptionBase::buildoption, "The template Object from which all the others will be built. \n"); inherited::declareOptions(ol); }
static const PPath& PLearn::ObjectGenerator::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::OracleObjectGenerator.
Definition at line 92 of file ObjectGenerator.h.
ObjectGenerator * PLearn::ObjectGenerator::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::Object.
Reimplemented in PLearn::OracleObjectGenerator.
Definition at line 46 of file ObjectGenerator.cc.
void PLearn::ObjectGenerator::forget | ( | ) | [virtual] |
Reimplemented in PLearn::OracleObjectGenerator.
Definition at line 63 of file ObjectGenerator.cc.
References generation_began.
Referenced by generateAllObjects().
{ generation_began = false; }
This will generate a list of all possible Objects.
By default, just loop over generateNextObject()
Definition at line 76 of file ObjectGenerator.cc.
References PLearn::TVec< T >::append(), forget(), generateNextObject(), generation_began, and PLearn::PP< T >::isNull().
{ TVec< PP<Object> > all_objs; forget(); while (true) { PP<Object> next_obj = generateNextObject(); if (next_obj.isNull()) break; // no new Object all_objs.append(next_obj); } generation_began = true; return all_objs; }
This will generate the next object in the list of all options MUST be define by a subclass.
Implemented in PLearn::OracleObjectGenerator.
Referenced by generateAllObjects().
Reimplemented from PLearn::Object.
Reimplemented in PLearn::OracleObjectGenerator.
Definition at line 92 of file ObjectGenerator.h.
bool PLearn::ObjectGenerator::generation_began [protected] |
Did we begin to generate new Objects???
Definition at line 55 of file ObjectGenerator.h.
Referenced by forget(), and generateAllObjects().
The template Object from which we will generate other Objects.
Definition at line 60 of file ObjectGenerator.h.
Referenced by build_(), and declareOptions().