#include <Object.h>
Inheritance diagram for PLearn::Object:
Public Types | |
typedef Object | inherited |
Public Member Functions | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual Object * | deepCopy (CopiesMap &copies) const |
Object () | |
SUBCLASS WRITING Note: all subclasses should define a default constructor (one that can be called without arguments), whose main role is to give a reasonable default value to all build options (see declareOptions). | |
virtual void | build () |
Should call simply inherited::build(), then this class's build_(). | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
virtual string | info () const |
returns a bit more informative string about object (default returns classname()) | |
virtual void | print (ostream &out) const |
void | readOptionVal (PStream &in, const string &optionname) |
Reads and sets the value for the specified option from the specified stream. | |
void | writeOptionVal (PStream &out, const string &optionname) const |
Writes the value of the specified option to the specified stream. | |
virtual string | getOptionsToSave () const |
returns a string of the names of all options to save (optionnames are to be separated by a space, and must be supported by writeOptionVal) | |
void | newwrite (PStream &out) const |
Serializes this object in the new format Classname(optionname=optionval; optionname=optionval; ...). | |
void | newread (PStream &in) |
reads and builds an object in the new format Classname(optionname=optionval; optionname=optionval; ...) | |
void | setOption (const string &optionname, const string &value) |
string | getOption (const string &optionname) const |
virtual void | changeOptions (const map< string, string > &name_value) |
void | changeOption (const string &optionname, const string &value) |
Non-virtual method calls virtual changeOptions. | |
virtual void | write (ostream &out) const |
virtual void | read (istream &in) |
virtual void | call (const string &methodname, int nargs, PStream &in_parameters, PStream &out_results) |
The call method is the standard way to allow for remote method invocation on instances of your class. | |
virtual void | run () |
Overload this for runnable objects (default method issues a runtime error) Runnable objects are objects that can be used as *THE* object of a .plearn script. | |
virtual void | oldread (istream &in) |
DEPRECATED For backward compatibility with old saved object. | |
virtual void | save (const string &filename) const |
This method is deprecated. | |
virtual void | load (const string &filename) |
This method is deprecated. | |
virtual | ~Object () |
Static Public Member Functions | |
string | _classname_ () |
OptionList & | _getOptionList_ () |
Object * | _new_instance_for_typemap_ () |
bool | _isa_ (Object *o) |
void | _static_initialize_ () |
Static Public Attributes | |
StaticInitializer | _static_initializer_ |
Protected Member Functions | |
void | prepareToSendResults (PStream &out, int nres) |
Static Protected Member Functions | |
void | declareOptions (OptionList &ol) |
redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options) ( see the declareOption function further down) | |
Private Member Functions | |
void | build_ () |
Definition at line 349 of file Object.h.
|
|
SUBCLASS WRITING Note: all subclasses should define a default constructor (one that can be called without arguments), whose main role is to give a reasonable default value to all build options (see declareOptions). Completing the actual building of the object is left to the build_() and build() methods (see below). |
|
|
|
Reimplemented in PLearn::RealMapping, and PLearn::SetOption. |
|
Reimplemented in PLearn::RealMapping, and PLearn::SetOption. |
|
Reimplemented in PLearn::RealMapping, and PLearn::SetOption. |
|
Reimplemented in PLearn::RealMapping, and PLearn::SetOption. |
|
Reimplemented in PLearn::RealMapping, and PLearn::SetOption. |
|
|
|
The call method is the standard way to allow for remote method invocation on instances of your class. This should result in reading nargs input parameters from in_parameters, call the appropriate method, and send results to out_results. A "Remote-callable method" is typically associated with an actual methods of your class, but it will usually differ in its "calling" conventions: its "name", number or input arguments, and number and nature of output results may differ. Here is what such a method should do: 1) Determine from the methodname what actual method to call. If the given methodname is none of those supported by your call method, call the parent's "call" Ex: inherited::call(methodname, nargs, in_parameters, out_results) 2) The number of arguments nargs may also influence what version of the method you want to call 3) read the narg arguments from in_parameters Ex: in_parameters >> age >> length >> n; 4) call the actual associated method 5) call prepareToSendResults(out_results, nres) where nres is the number of result parameters. 6) send the nres result parameters to out_results Ex: out_results << res1 << res2 <<res3; 7) call out_results.flush() If anything goes wrong during the process (bad arguments, etc...) simply call PLERROR with a meaningful message. Definition at line 319 of file Object.cc. References PLERROR. |
|
Non-virtual method calls virtual changeOptions.
Definition at line 95 of file Object.cc. References changeOptions(). |
|
This method should be used, rather than setOption, when modifying some options of an already built object. Default version simply calls setOption, but subclasses should override it to execute any code required to put the object in a consistent state. If the set of options would put the object in an inconsistent state, a runtime error should be issued. Definition at line 84 of file Object.cc. References setOption(). Referenced by changeOption(). |
|
|
|
Reimplemented in PLearn::RealMapping, and PLearn::SetOption. |
|
This is a generic method to be able to retrieve the value of an option supported by the object (and its derivatives). The option value is returned as a string and MUST be converted to the correct type before use. Definition at line 72 of file Object.cc. References PLearn::removeblanks(), and writeOptionVal(). |
|
Reimplemented in PLearn::RealMapping, and PLearn::SetOption. Definition at line 59 of file Object.cc. Referenced by getOptionsToSave(), newread(), readOptionVal(), and writeOptionVal(). |
|
returns a string of the names of all options to save (optionnames are to be separated by a space, and must be supported by writeOptionVal)
Definition at line 226 of file Object.cc. References PLearn::OptionBase::flag_t, and getOptionList(). Referenced by newwrite(). |
|
|
This method is deprecated. It simply calls the generic PLearn load function (that can load any PLearn object): PLearn::load(filename, *this) So you should call PLearn::load directly (it's defined in pl_io.h). Reimplemented in PLearn::Learner. Definition at line 333 of file Object.cc. References PLearn::load(). |
|
Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be. Typical implementation: void CLASS_OF_THIS::makeDeepCopyFromShallowCopy(CopiesMap& copies) { SUPERCLASS_OF_THIS::makeDeepCopyFromShallowCopy(copies); member_ptr = member_ptr->deepCopy(copies); member_smartptr = member_smartptr->deepCopy(copies); member_mat.makeDeepCopyFromShallowCopy(copies); member_vec.makeDeepCopyFromShallowCopy(copies); ... } Reimplemented in PLearn::Kernel, PLearn::AdaptGradientOptimizer, PLearn::ConjGradientOptimizer, PLearn::GradientOptimizer, PLearn::MultiInstanceNNet, PLearn::EmpiricalDistribution, PLearn::GaussianDistribution, PLearn::Learner, PLearn::NeighborhoodSmoothnessNNet, PLearn::NeuralNet, PLearn::NNet, PLearn::PLearner, PLearn::EmbeddedSequentialLearner, PLearn::SequentialLearner, and PLearn::SequentialModelSelector. Referenced by PLearn::deepCopyField(). |
|
reads and builds an object in the new format Classname(optionname=optionval; optionname=optionval; ...)
Definition at line 241 of file Object.cc. References build(), c_str(), classname(), PLearn::PStream::get(), PLearn::PStream::getline(), getOptionList(), PLearn::PStream::peek(), PLERROR, readOptionVal(), PLearn::removeblanks(), PLearn::PStream::skipBlanksAndComments(), PLearn::PStream::skipBlanksAndCommentsAndSeparators(), and PLearn::PStream::unget(). Referenced by PLearn::operator>>(), read(), and PLearn::readObject(). |
|
Serializes this object in the new format Classname(optionname=optionval; optionname=optionval; ...).
Definition at line 283 of file Object.cc. References classname(), getOptionsToSave(), PLearn::split(), PLearn::PStream::write(), and writeOptionVal(). Referenced by PLearn::operator<<(), and write(). |
|
DEPRECATED For backward compatibility with old saved object.
Reimplemented in PLearn::StatsCollector, PLearn::StatsIterator, PLearn::MeanStatsIterator, PLearn::ExpMeanStatsIterator, PLearn::StddevStatsIterator, PLearn::StderrStatsIterator, PLearn::SharpeRatioStatsIterator, PLearn::MinStatsIterator, PLearn::MaxStatsIterator, PLearn::LiftStatsIterator, PLearn::QuantilesStatsIterator, PLearn::Optimizer, PLearn::Variable, PLearn::ForwardVMatrix, PLearn::VMatrix, and PLearn::Learner. Definition at line 327 of file Object.cc. References PLERROR. Referenced by read(). |
|
Definition at line 368 of file Object.h. References prepareToSendResults(). Referenced by prepareToSendResults(). |
|
Prints a human-readable, short (not necessarily complete) description of this object instance (default prints info()). This is what is called by operator<< on Object Reimplemented in PLearn::RealMapping, PLearn::StatsCollector, PLearn::Variable, PLearn::VMatrix, and PLearn::VVec. Definition at line 110 of file Object.cc. References PLearn::endl(). Referenced by PLearn::operator<<(). |
|
DEPRECATED (use the declareOption / build_ mecanism instead, that provides automatic serialization) The read method is the counterpart of the write method. It should be able to reconstruct an object that has been previously written with the write method. The current implementation automatically decides whether to call newread() (which is based on the new declareOptions/build mechanism) or oldread() for backward compatibility (if the header is of the form <classname>). Reimplemented in PLearn::RealMapping. Definition at line 306 of file Object.cc. References newread(), oldread(), PLearn::PStream::peek(), and PLearn::ws(). Referenced by PLearn::readObject(). |
|
Reads and sets the value for the specified option from the specified stream.
Definition at line 118 of file Object.cc. References classname(), getOptionList(), PLearn::OptionList, PLERROR, and PLearn::toint(). Referenced by newread(), and setOption(). |
|
Overload this for runnable objects (default method issues a runtime error) Runnable objects are objects that can be used as *THE* object of a .plearn script. The run() method specifies what they should do when executed. Reimplemented in PLearn::NearestNeighborPredictionCost, PLearn::RunObject, PLearn::ShellScript, PLearn::Experiment, PLearn::GenerateDecisionPlot, PLearn::Grapher, PLearn::PTester, PLearn::SequentialValidation, PLearn::PTester, and PLearn::Train. Definition at line 324 of file Object.cc. References PLERROR. Referenced by PLearn::VMatLanguage::run(). |
|
This method is deprecated. It simply calls the generic PLearn save function (that can save any PLearn object): PLearn::save(filename, *this) So you should call PLearn::save directly (it's defined in pl_io.h). Reimplemented in PLearn::ForwardVMatrix, PLearn::VMatrix, and PLearn::Learner. Definition at line 330 of file Object.cc. References PLearn::save(). |
|
This is a generic method to be able to set an option in an object in the most generic manner value is a string representation of the value to be set. It should only be called for initial construction or reloading of an object, prior to calling build(); To modify the options of an already built object, call changeOptions or changeOption instead. If no option with that name exists, it causes an "Unknown option" runtime error. Definition at line 65 of file Object.cc. References readOptionVal(). Referenced by changeOptions(). |
|
DEPRECATED (use the declareOption / build_ mecanism instead, that provides automatic serialization) The write method should write a complete description of the object to the given stream, that should be enough to later reconstruct it. (a somewhat human-readable ascii format is usually preferred). The new default version simply calls newwrite(...) which simply writes all the "options" declared in declareOptions, so there is no need to overload write in subclasses. Old classes that still overload write should progressively be moved to the new declareOptions/build mechanism. Reimplemented in PLearn::RealMapping, and PLearn::Variable. Definition at line 300 of file Object.cc. References newwrite(). |
|
Writes the value of the specified option to the specified stream.
Definition at line 181 of file Object.cc. References getOptionList(), PLERROR, and PLearn::toint(). Referenced by getOption(), and newwrite(). |
|
Reimplemented in PLearn::RealMapping, and PLearn::SetOption. |