PLearn 0.1
|
#include <RPPath.h>
Public Member Functions | |
RPPath () | |
Default constructor. | |
PP< RPPath > | absolute () |
Return the RPPath object that represents the same path, but in its absolute form. | |
string | canonical () |
Forwarded to the underlying PPath. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual RPPath * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
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 | |
PPath | path |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
static void | declareMethods (RemoteMethodMap &rmm) |
Declare methods that are intended to be remote-callable. | |
Private Types | |
typedef Object | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
typedef Object PLearn::RPPath::inherited [private] |
Reimplemented from PLearn::Object.
string PLearn::RPPath::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
OptionList & PLearn::RPPath::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
RemoteMethodMap & PLearn::RPPath::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Reimplemented from PLearn::Object.
Object * PLearn::RPPath::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
StaticInitializer RPPath::_static_initializer_ & PLearn::RPPath::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Return the RPPath object that represents the same path, but in its absolute form.
Definition at line 107 of file RPPath.cc.
Referenced by declareMethods().
{ PP<RPPath> abs_path = new RPPath(); abs_path->path = path.absolute(); abs_path->build(); return abs_path; }
void PLearn::RPPath::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 92 of file RPPath.cc.
{ inherited::build(); build_(); }
void PLearn::RPPath::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::Object.
Definition at line 101 of file RPPath.cc.
{}
string PLearn::RPPath::canonical | ( | ) |
Forwarded to the underlying PPath.
Definition at line 118 of file RPPath.cc.
Referenced by declareMethods().
{ return path.canonical(); }
string PLearn::RPPath::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
void PLearn::RPPath::declareMethods | ( | RemoteMethodMap & | rmm | ) | [static, protected] |
Declare methods that are intended to be remote-callable.
If you use this mechanism, you don't usually need to override the call method in derived classes. The typical form of this method is as follows:
static void MyDerivedClass::declareMethods(RemoteMethodMap& rmm) { // Insert a backpointer to inherited methods; note that this // mechanism is different from that of declareOptions() rmm.inherited(inherited::_getRemoteMethodMap_()); // Mind the extra pair of parenthesis around the docstrings. // They are necessary for proper construction of documentation. declareMethod(rmm, "method1", &MyDerivedClass::method1, (BodyDoc("Main documentation for the method"), ArgDoc ("arg1_name", "Documentation for argument1"), ArgDoc ("arg2_name", "Documentation for argument2"), // ... other ArgDoc here ... RetDoc ("Documentation for the return value"))); // Other calls to declareMethod() as appropriate to expose the // public remote-callable interface }
IMPORTANT REMARKS:
The types of methods that can be directly declared in this manner is restricted to methods that don't have any "result-arguments" (and are either void, or *return* their result). But in C/C++ it is customary to implement "multiple results" by passing them as "result-arguments" to the call. You can't use declareMethod on such a method: you'll first have to write a wrapper method of the correct form that you can declare with declareMethod. To *return* multiple results, you should actually return a *tuple*.
Ex: if you have a method of class PLearner with 2 "result arguments" like:
virtual void computeOutputAndCosts(const Vec& input, const Vec& target, Vec& output, Vec& costs) const;
you can't declare it directly with declareMethod, so you'll have to write a wrapper-method that you can declare, like the following:
tuple<Vec,Vec> PLearner::remote_computeOutputAndCosts(const Vec& input, const Vec& target) const { Vec output; Vec costs; computeOutputAndCosts(input,target,output,costs); return make_tuple(output, costs); }
The policy is to name such wapper methods destined for the remote method mechanism by prepending the suffix remote_, and usually to keep them private and non-virtual.
Note that from the calling-convention perspective of a C++ process remote-calling such a tuple-returning method, the results will be received as "multiple results" corresponding to the elements of the tuple, rather than as a "single result" of type tuple. If instead you *really* want your tuple to be received as a single tuple then you should return a tuple of your tuple.
Also beware, if you have several C++ methods with the same name, overloaded for different types of arguments, and you want to make them all remote callable, you should declare them with *different* corresponding string names in declareMethods. Indeed, the remote method mechanism can only distinguish methods based on their string name and number of arguments, but not on the types of the arguments.
rmm | RemoteMethodMap to be constructed for the current class. |
Reimplemented from PLearn::Object.
Definition at line 78 of file RPPath.cc.
References absolute(), canonical(), PLearn::declareMethod(), and PLearn::RemoteMethodMap::inherited().
{ rmm.inherited(inherited::_getRemoteMethodMap_()); declareMethod(rmm, "absolute", &RPPath::absolute, (BodyDoc("Return the absolute path as a RPPath object."))); declareMethod(rmm, "canonical", &RPPath::canonical, (BodyDoc("Return the canonic path."))); }
void PLearn::RPPath::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::Object.
Definition at line 65 of file RPPath.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), and path.
{ declareOption(ol, "path", &RPPath::path, OptionBase::buildoption, "Path (to file or directory) that is being manipulated."); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::RPPath::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::Object.
Definition at line 73 of file RPPath.h.
:
//##### Protected Options ###############################################
Reimplemented from PLearn::Object.
OptionList & PLearn::RPPath::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
OptionMap & PLearn::RPPath::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
RemoteMethodMap & PLearn::RPPath::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
void PLearn::RPPath::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::Object.
Definition at line 126 of file RPPath.cc.
{ inherited::makeDeepCopyFromShallowCopy(copies); }
Reimplemented from PLearn::Object.
Definition at line 55 of file RPPath.h.
Referenced by declareOptions().