PLearn 0.1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | Private Types | Private Member Functions
PLearn::RunObject Class Reference

#include <RunObject.h>

Inheritance diagram for PLearn::RunObject:
Inheritance graph
[legend]
Collaboration diagram for PLearn::RunObject:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RunObject ()
 Default constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual RunObjectdeepCopy (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 PPathdeclaringFile ()

Public Attributes

PP< Objectunderlying_object
PPath save_object_name
TVec< PP< Object > > objects
TVec< PPathsave_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.

Detailed Description

Definition at line 52 of file RunObject.h.


Member Typedef Documentation

Reimplemented from PLearn::Object.

Definition at line 57 of file RunObject.h.


Constructor & Destructor Documentation

PLearn::RunObject::RunObject ( )

Default constructor.

Definition at line 53 of file RunObject.cc.

                    :
    run_objects(false)
{}

Member Function Documentation

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.

bool PLearn::RunObject::_isa_ ( const Object o) [static]

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_().

Here is the call graph for this function:

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);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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);
}

Here is the call graph for this function:

static const PPath& PLearn::RunObject::declaringFile ( ) [inline, static]

Reimplemented from PLearn::Object.

Definition at line 107 of file RunObject.h.

RunObject * PLearn::RunObject::deepCopy ( CopiesMap copies) const [virtual]

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!");
}

Here is the call graph for this function:

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]);
    }
}

Here is the call graph for this function:


Member Data Documentation

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().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines