PLearn 0.1
|
#include <RunObject.h>
Public Member Functions | |
RunObject () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual RunObject * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
virtual void | run () |
Does nothing, but does not raise an error. | |
Static Public Member Functions | |
static string | _classname_ () |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static Object * | _new_instance_for_typemap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
Public Attributes | |
PP< Object > | underlying_object |
PPath | save_object_name |
TVec< PP< Object > > | objects |
TVec< PPath > | save_files |
bool | run_objects |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares this class' options. | |
Private Types | |
typedef Object | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Definition at line 52 of file RunObject.h.
typedef Object PLearn::RunObject::inherited [private] |
Reimplemented from PLearn::Object.
Definition at line 57 of file RunObject.h.
PLearn::RunObject::RunObject | ( | ) |
string PLearn::RunObject::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 67 of file RunObject.cc.
OptionList & PLearn::RunObject::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 67 of file RunObject.cc.
RemoteMethodMap & PLearn::RunObject::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 67 of file RunObject.cc.
Reimplemented from PLearn::Object.
Definition at line 67 of file RunObject.cc.
Object * PLearn::RunObject::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 67 of file RunObject.cc.
StaticInitializer RunObject::_static_initializer_ & PLearn::RunObject::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 67 of file RunObject.cc.
void PLearn::RunObject::build | ( | ) | [virtual] |
Post-constructor.
The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.
Reimplemented from PLearn::Object.
Definition at line 121 of file RunObject.cc.
References PLearn::Object::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::RunObject::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::Object.
Definition at line 99 of file RunObject.cc.
References PLearn::TVec< T >::append(), PLearn::PPath::isEmpty(), PLearn::TVec< T >::isEmpty(), PLearn::TVec< T >::length(), objects, PLASSERT, PLDEPRECATED, PLearn::TVec< T >::resize(), run_objects, save_files, save_object_name, and underlying_object.
Referenced by build().
{ // Deal with deprecated options. if (underlying_object) { PLDEPRECATED("In RunObject::build_ - Option 'underlying_object' is now" " deprecated, please use the 'objects' option (note that " "this is still going to work as usual)"); PLASSERT( objects.isEmpty() && !run_objects ); run_objects = false; objects.resize(0); objects.append(underlying_object); } if (!save_object_name.isEmpty()) { PLDEPRECATED("In RunObject::build_ - Option 'save_object_name' is now" "deprecated, please use the 'save_files' option (note " "that this is still going to work as usual)"); PLASSERT(save_files.isEmpty() && !run_objects && objects.length() == 1); save_files.resize(0); save_files.append(save_object_name); } }
string PLearn::RunObject::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 67 of file RunObject.cc.
void PLearn::RunObject::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares this class' options.
Reimplemented from PLearn::Object.
Definition at line 69 of file RunObject.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::Object::declareOptions(), PLearn::OptionBase::learntoption, objects, run_objects, save_files, save_object_name, and underlying_object.
{ TVec<PPath> save_files; declareOption(ol, "objects", &RunObject::objects, OptionBase::buildoption, "The objects that need being built, run and / or saved."); declareOption(ol, "run_objects", &RunObject::run_objects, OptionBase::buildoption, "If set to 'true', objects will be run with this RunObject."); declareOption(ol, "save_files", &RunObject::save_files, OptionBase::buildoption, "If provided, the resulting objects will be saved. This vector must\n" "either have same length as 'objects', or be of length one, in which\n" "case each object 'i' will be saved as '<basename>_i.<extension>'."); declareOption(ol, "underlying_object", &RunObject::underlying_object, OptionBase::learntoption, "DEPRECATED: The underlying object to be built."); declareOption(ol, "save_object_name", &RunObject::save_object_name, OptionBase::learntoption, "DEPRECATED: If provided, the object will be saved to this file after it is built."); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::RunObject::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::Object.
Definition at line 107 of file RunObject.h.
Reimplemented from PLearn::Object.
Definition at line 67 of file RunObject.cc.
OptionList & PLearn::RunObject::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 67 of file RunObject.cc.
OptionMap & PLearn::RunObject::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 67 of file RunObject.cc.
RemoteMethodMap & PLearn::RunObject::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 67 of file RunObject.cc.
void PLearn::RunObject::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::Object.
Definition at line 127 of file RunObject.cc.
References PLearn::Object::makeDeepCopyFromShallowCopy(), and PLERROR.
{ inherited::makeDeepCopyFromShallowCopy(copies); // ### Call deepCopyField on all "pointer-like" fields // ### that you wish to be deepCopied rather than // ### shallow-copied. // ### ex: // deepCopyField(trainvec, copies); // ### Remove this line when you have fully implemented this method. PLERROR("RunObject::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
void PLearn::RunObject::run | ( | ) | [virtual] |
Does nothing, but does not raise an error.
Reimplemented from PLearn::Object.
Definition at line 144 of file RunObject.cc.
References PLearn::PPath::extension(), i, PLearn::TVec< T >::isEmpty(), PLearn::TVec< T >::length(), PLearn::PPath::no_extension(), objects, PLASSERT, run_objects, PLearn::save(), save_files, and PLearn::tostring().
{ if (run_objects) for (int i = 0; i < objects.length(); i++) objects[i]->run(); PLASSERT( save_files.isEmpty() || save_files.length() == 1 || save_files.length() == objects.length() ); if (!save_files.isEmpty()) { TVec<PPath> paths = save_files; if (paths.length() != objects.length()) { // Automatically generate paths with an increasing counter. PLASSERT( paths.length() == 1 ); PPath basepath = paths[0]; PPath no_ext = basepath.no_extension(); string ext = basepath.extension(true); paths = TVec<PPath>(objects.length()); for (int i = 0; i < paths.length(); i++) paths[i] = no_ext + "_" + tostring(i) + ext; } PLASSERT( objects.length() == paths.length() ); for (int i = 0; i < objects.length(); i++) PLearn::save(paths[i], objects[i]); } }
Reimplemented from PLearn::Object.
Definition at line 107 of file RunObject.h.
Definition at line 77 of file RunObject.h.
Referenced by build_(), declareOptions(), and run().
Definition at line 79 of file RunObject.h.
Referenced by build_(), declareOptions(), and run().
Definition at line 78 of file RunObject.h.
Referenced by build_(), declareOptions(), and run().
Definition at line 75 of file RunObject.h.
Referenced by build_(), and declareOptions().
Definition at line 74 of file RunObject.h.
Referenced by build_(), and declareOptions().