PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <ObjectGraphIteratorTest.h>
Public Member Functions | |
ObjectGraphIteratorTest () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual ObjectGraphIteratorTest * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
virtual void | perform () |
The method performing the test. | |
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 () |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Private Types | |
typedef PTest | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
The first sentence should be a BRIEF DESCRIPTION of what the class does.
Place the rest of the class programmer documentation here. Doxygen supports Javadoc-style comments. See http://www.doxygen.org/manual.html
Definition at line 61 of file ObjectGraphIteratorTest.h.
typedef PTest PLearn::ObjectGraphIteratorTest::inherited [private] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file ObjectGraphIteratorTest.h.
PLearn::ObjectGraphIteratorTest::ObjectGraphIteratorTest | ( | ) |
Default constructor.
Definition at line 66 of file ObjectGraphIteratorTest.cc.
{ // ... // ### You may (or not) want to call build_() to finish building the object // ### (doing so assumes the parent classes' build_() have been called too // ### in the parent classes' constructors, something that you must ensure) }
string PLearn::ObjectGraphIteratorTest::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 61 of file ObjectGraphIteratorTest.cc.
OptionList & PLearn::ObjectGraphIteratorTest::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 61 of file ObjectGraphIteratorTest.cc.
RemoteMethodMap & PLearn::ObjectGraphIteratorTest::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 61 of file ObjectGraphIteratorTest.cc.
Reimplemented from PLearn::PTest.
Definition at line 61 of file ObjectGraphIteratorTest.cc.
Object * PLearn::ObjectGraphIteratorTest::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 61 of file ObjectGraphIteratorTest.cc.
StaticInitializer ObjectGraphIteratorTest::_static_initializer_ & PLearn::ObjectGraphIteratorTest::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 61 of file ObjectGraphIteratorTest.cc.
void PLearn::ObjectGraphIteratorTest::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::PTest.
Definition at line 79 of file ObjectGraphIteratorTest.cc.
{ inherited::build(); build_(); }
void PLearn::ObjectGraphIteratorTest::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::PTest.
Definition at line 125 of file ObjectGraphIteratorTest.cc.
{ // ### This method should do the real building of the object, // ### according to set 'options', in *any* situation. // ### Typical situations include: // ### - Initial building of an object from a few user-specified options // ### - Building of a "reloaded" object: i.e. from the complete set of all serialised options. // ### - Updating or "re-building" of an object after a few "tuning" options have been modified. // ### You should assume that the parent class' build_() has already been called. }
string PLearn::ObjectGraphIteratorTest::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 61 of file ObjectGraphIteratorTest.cc.
void PLearn::ObjectGraphIteratorTest::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::PTest.
Definition at line 105 of file ObjectGraphIteratorTest.cc.
{ // ### Declare all of this object's options here // ### For the "flags" of each option, you should typically specify // ### one of OptionBase::buildoption, OptionBase::learntoption or // ### OptionBase::tuningoption. Another possible flag to be combined with // ### is OptionBase::nosave // ### ex: // declareOption(ol, "myoption", &ObjectGraphIteratorTest::myoption, OptionBase::buildoption, // "Help text describing this option"); // ... // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::ObjectGraphIteratorTest::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::PTest.
Definition at line 88 of file ObjectGraphIteratorTest.h.
:
//##### Protected Options ###############################################
ObjectGraphIteratorTest * PLearn::ObjectGraphIteratorTest::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 61 of file ObjectGraphIteratorTest.cc.
OptionList & PLearn::ObjectGraphIteratorTest::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 61 of file ObjectGraphIteratorTest.cc.
OptionMap & PLearn::ObjectGraphIteratorTest::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 61 of file ObjectGraphIteratorTest.cc.
RemoteMethodMap & PLearn::ObjectGraphIteratorTest::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 61 of file ObjectGraphIteratorTest.cc.
void PLearn::ObjectGraphIteratorTest::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::PTest.
Definition at line 88 of file ObjectGraphIteratorTest.cc.
References 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("ObjectGraphIteratorTest::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
void PLearn::ObjectGraphIteratorTest::perform | ( | ) | [virtual] |
The method performing the test.
A typical test consists in some output (to pout and / or perr), and updates of this object's options.
Reimplemented from PLearn::PTest.
Definition at line 258 of file ObjectGraphIteratorTest.cc.
References PLearn::ObjectGraphIterator::BreadthOrder, PLearn::PStream::copies_map_out, PLearn::ObjectGraphIterator::DepthPreOrder, PLearn::endl(), PLearn::flush(), i, PLearn::iterate(), PLearn::memfun_broadcast(), PLearn::memfun_broadcast_optname(), PLearn::PLearnError::message(), PLearn::X::method1(), PLearn::X::method2(), PLearn::num_tests, PLearn::openString(), PLearn::PStream::plearn_ascii, PLearn::pout, PLearn::Y::printName(), PLearn::X::printName(), PLearn::PStream::setMode(), and PLearn::test_objects.
{ try { pout.setMode(PStream::plearn_ascii); for (int i=0 ; i<num_tests ; ++i) { string test_object = test_objects[i]; cout << endl << "- - - - - - - - - - -" << endl << "Building object structure from:" << endl << test_object << endl; PStream strin = openString(test_object, PStream::plearn_ascii); PP<Object> o; strin >> o; cout << endl << "Built structure: " << endl; pout << o << flush; pout.copies_map_out.clear(); cout << endl << "Now traversing the graph in breadth-first:" << endl; iterate(ObjectGraphIterator(o, ObjectGraphIterator::BreadthOrder, true), ObjectGraphIterator()); cout << endl << "Traversing only Y objects in depth-first:" << endl; iterate(ObjectGraphIterator(o, ObjectGraphIterator::DepthPreOrder, true, "Y"), ObjectGraphIterator()); cout << endl << "Broadcast a call to X::printName()" << endl; memfun_broadcast(o, &X::printName); cout << endl << "Broadcast a call to Y::printName()" << endl; memfun_broadcast(o, &Y::printName); cout << endl << "Broadcast a breadth-first call to X::method1(\"foo\")" << endl; memfun_broadcast(o, &X::method1, string("foo"), ObjectGraphIterator::BreadthOrder); cout << endl << "Broadcast a breadth-first call to X::method1(option_name)" << endl; memfun_broadcast_optname(o, &X::method1, ObjectGraphIterator::BreadthOrder); cout << endl << "Broadcast a breadth-first call to X::method2(\"foo\",42)" << endl; memfun_broadcast(o, &X::method2, string("foo"), 42, ObjectGraphIterator::BreadthOrder); } } catch(const PLearnError& e) { cerr << "FATAL ERROR: " << e.message() << endl; } catch (...) { cerr << "FATAL ERROR: uncaught unknown exception " << "(ex: out-of-memory when allocating a matrix)" << endl; } }
Reimplemented from PLearn::PTest.
Definition at line 88 of file ObjectGraphIteratorTest.h.