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::Redirect Class Reference

#include <Redirect.h>

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

List of all members.

Public Member Functions

 Redirect ()
 Default constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual RedirectdeepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
virtual void run ()
 Execute the shell commands.

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

PPath filename
string what
bool active

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 Redirect.h.


Member Typedef Documentation

Reimplemented from PLearn::Object.

Definition at line 57 of file Redirect.h.


Constructor & Destructor Documentation

PLearn::Redirect::Redirect ( )

Default constructor.

Definition at line 49 of file Redirect.cc.

                  :
    active(true)
    /* ### Initialize all fields to their default value */
{
    // ...

    // ### You may or may not want to call build_() to finish building the object
    // build_();
}

Member Function Documentation

string PLearn::Redirect::_classname_ ( ) [static]

Reimplemented from PLearn::Object.

Definition at line 61 of file Redirect.cc.

OptionList & PLearn::Redirect::_getOptionList_ ( ) [static]

Reimplemented from PLearn::Object.

Definition at line 61 of file Redirect.cc.

RemoteMethodMap & PLearn::Redirect::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::Object.

Definition at line 61 of file Redirect.cc.

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

Reimplemented from PLearn::Object.

Definition at line 61 of file Redirect.cc.

Object * PLearn::Redirect::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::Object.

Definition at line 61 of file Redirect.cc.

StaticInitializer Redirect::_static_initializer_ & PLearn::Redirect::_static_initialize_ ( ) [static]

Reimplemented from PLearn::Object.

Definition at line 61 of file Redirect.cc.

void PLearn::Redirect::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 96 of file Redirect.cc.

References PLearn::Object::build(), and build_().

Here is the call graph for this function:

void PLearn::Redirect::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::Object.

Definition at line 84 of file Redirect.cc.

Referenced by build().

{
    // ### 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.
}

Here is the caller graph for this function:

string PLearn::Redirect::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 61 of file Redirect.cc.

void PLearn::Redirect::declareOptions ( OptionList ol) [static, protected]

Declares this class' options.

Reimplemented from PLearn::Object.

Definition at line 63 of file Redirect.cc.

References active, PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::Object::declareOptions(), filename, and what.

{
    // ### 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

    declareOption(ol, "active", &Redirect::active, OptionBase::buildoption,
                  "Will do the redirect only if true. Else do nothing.");

    declareOption(ol, "what", &Redirect::what, OptionBase::buildoption,
                  "The string perr or pout. Indicated what will be redirected.");

    declareOption(ol, "filename", &Redirect::filename, OptionBase::buildoption,
                  "The file where the PStream will be redirected.");

    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 104 of file Redirect.h.

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

Reimplemented from PLearn::Object.

Definition at line 61 of file Redirect.cc.

OptionList & PLearn::Redirect::getOptionList ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 61 of file Redirect.cc.

OptionMap & PLearn::Redirect::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 61 of file Redirect.cc.

RemoteMethodMap & PLearn::Redirect::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 61 of file Redirect.cc.

void PLearn::Redirect::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::Object.

Definition at line 102 of file Redirect.cc.

References PLearn::deepCopyField(), filename, PLearn::Object::makeDeepCopyFromShallowCopy(), and what.

Here is the call graph for this function:

void PLearn::Redirect::run ( ) [virtual]

Execute the shell commands.

Reimplemented from PLearn::Object.

Definition at line 112 of file Redirect.cc.

References active, filename, PLearn::openFile(), PLearn::perr, PLERROR, PLearn::pout, PLearn::PStream::raw_ascii, and what.

                   {
    //do the redirection
    if(!active)
        return;
    if(what=="perr"){
        //the old is closed automatically
        perr=openFile(filename,PStream::raw_ascii,"w",false,true);
    }else if(what=="pout"){
        //the old is closed automatically
        pout=openFile(filename,PStream::raw_ascii,"w",false,true);
    }else
        PLERROR("In Redirect::run() - unknow stream %s to redirect",what.c_str());
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::Object.

Definition at line 104 of file Redirect.h.

Definition at line 75 of file Redirect.h.

Referenced by declareOptions(), and run().

Definition at line 73 of file Redirect.h.

Referenced by declareOptions(), makeDeepCopyFromShallowCopy(), and run().

Definition at line 74 of file Redirect.h.

Referenced by declareOptions(), makeDeepCopyFromShallowCopy(), and run().


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