PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <InterfunctionXchgTest.h>
Public Member Functions | |
InterfunctionXchgTest () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual InterfunctionXchgTest * | 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. | |
Static Protected Attributes | |
static string | python_code = " sys.stdout.flush()\n" |
Static Python code. | |
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 InterfunctionXchgTest.h.
typedef PTest PLearn::InterfunctionXchgTest::inherited [private] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file InterfunctionXchgTest.h.
PLearn::InterfunctionXchgTest::InterfunctionXchgTest | ( | ) |
Default constructor.
Definition at line 63 of file InterfunctionXchgTest.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::InterfunctionXchgTest::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 58 of file InterfunctionXchgTest.cc.
OptionList & PLearn::InterfunctionXchgTest::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 58 of file InterfunctionXchgTest.cc.
RemoteMethodMap & PLearn::InterfunctionXchgTest::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 58 of file InterfunctionXchgTest.cc.
Reimplemented from PLearn::PTest.
Definition at line 58 of file InterfunctionXchgTest.cc.
Object * PLearn::InterfunctionXchgTest::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 58 of file InterfunctionXchgTest.cc.
StaticInitializer InterfunctionXchgTest::_static_initializer_ & PLearn::InterfunctionXchgTest::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 58 of file InterfunctionXchgTest.cc.
void PLearn::InterfunctionXchgTest::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 76 of file InterfunctionXchgTest.cc.
{ inherited::build(); build_(); }
void PLearn::InterfunctionXchgTest::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::PTest.
Definition at line 122 of file InterfunctionXchgTest.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::InterfunctionXchgTest::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 58 of file InterfunctionXchgTest.cc.
void PLearn::InterfunctionXchgTest::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::PTest.
Definition at line 102 of file InterfunctionXchgTest.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", &InterfunctionXchgTest::myoption, OptionBase::buildoption, // "Help text describing this option"); // ... // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::InterfunctionXchgTest::declaringFile | ( | ) | [inline, static] |
InterfunctionXchgTest * PLearn::InterfunctionXchgTest::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 58 of file InterfunctionXchgTest.cc.
OptionList & PLearn::InterfunctionXchgTest::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 58 of file InterfunctionXchgTest.cc.
OptionMap & PLearn::InterfunctionXchgTest::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 58 of file InterfunctionXchgTest.cc.
RemoteMethodMap & PLearn::InterfunctionXchgTest::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 58 of file InterfunctionXchgTest.cc.
void PLearn::InterfunctionXchgTest::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::PTest.
Definition at line 85 of file InterfunctionXchgTest.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("InterfunctionXchgTest::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
void PLearn::InterfunctionXchgTest::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 153 of file InterfunctionXchgTest.cc.
References PLearn::endl(), PLearn::PLearnError::message(), PLearn::openString(), PLearn::PStream::plearn_ascii, python_code, and PLearn::tostring().
{ cout << "Python code to be executed: " << endl << ">>>" << python_code << "<<<" << endl; PP<PythonCodeSnippet> python = new PythonCodeSnippet(python_code); PP<PythonCodeSnippet> python_other = new PythonCodeSnippet(python_code, true); python->build(); python_other->build(); string survivor = "This string should survive within the Python environment"; cout << "Setting the string: '" << survivor << "'" << endl; python->invoke("set_value", survivor); cout << "Read back the string: '" << python->invoke("get_value").as<string>() << "'" << endl; cout << "Trying to read back from second snippet:" << endl; try { string s = python_other->invoke("get_value").as<string>(); cout << "Read back the string: '" << s << "'" << endl; } catch (const PythonException& e) { string exception_msg = e.message(); // Remove system dependent strings from the error message. boost::regex memory_adr("0x[abcdef0123456789]{6,}", boost::regex::perl|boost::regex::icase); string msg_without_sys_dependent_data = regex_replace(exception_msg, memory_adr, "0x[memory_address]"); boost::regex python_ver("Python 2\\.[0-9](\\.[0-9])?", boost::regex::perl|boost::regex::icase); msg_without_sys_dependent_data = regex_replace(msg_without_sys_dependent_data, python_ver, "Python 2.X.Y"); boost::regex python_path(": /(.)+/python", boost::regex::perl|boost::regex::icase); msg_without_sys_dependent_data = regex_replace(msg_without_sys_dependent_data, python_path, ": /path/python"); boost::regex except_display("<type 'exceptions.([a-z]+)'>", boost::regex::perl|boost::regex::icase); msg_without_sys_dependent_data = regex_replace(msg_without_sys_dependent_data, except_display, "\\1"); boost::regex extra_info("__class__(.)*message = [^\\n]+$\\n", boost::regex::perl|boost::regex::icase); msg_without_sys_dependent_data = regex_replace(msg_without_sys_dependent_data, extra_info, ""); boost::regex blank_line("^( )+$", boost::regex::perl); msg_without_sys_dependent_data = regex_replace(msg_without_sys_dependent_data, blank_line, ""); cout << "Caught Python Exception: '" << msg_without_sys_dependent_data << "'" << endl; } catch (const PLearnError& e) { cout << "Caught PLearn Exception: '" << e.message() << "'" << endl; } catch (...) { cout << "Caught unknown exception..." << endl; } try { map<string,int> mapsd; string str_mapsd = "{ Oui:16 il:32 est:64 juste:128 et:256 bon:512 }"; PStream is_mapsd = openString(str_mapsd, PStream::plearn_ascii); is_mapsd >> mapsd; python_other->setGlobalObject("some_global_map", PythonObjectWrapper(mapsd)); cout << "Associated 'some_global_map' with: " << tostring(mapsd) << endl; cout << "Read back from Python environment: " << tostring(python_other->getGlobalObject("some_global_map").as< map<string,int> >()) << endl; python_other->invoke("print_global_map"); cout << "Dump of the 'python_other' compiled environment" << endl; } 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 InterfunctionXchgTest.h.
string PLearn::InterfunctionXchgTest::python_code = " sys.stdout.flush()\n" [static, protected] |
Static Python code.
Definition at line 106 of file InterfunctionXchgTest.h.