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

The first sentence should be a BRIEF DESCRIPTION of what the class does. More...

#include <TupleTest.h>

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

List of all members.

Public Member Functions

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

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.

Detailed Description

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

Todo:
Write class to-do's here if there are any.
Deprecated:
Write deprecated stuff here if there is any. Indicate what else should be used instead.

Definition at line 57 of file TupleTest.h.


Member Typedef Documentation

Reimplemented from PLearn::PTest.

Definition at line 59 of file TupleTest.h.


Constructor & Destructor Documentation

PLearn::TupleTest::TupleTest ( )

Default constructor.

Definition at line 57 of file TupleTest.cc.

{}

Member Function Documentation

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

Reimplemented from PLearn::PTest.

Definition at line 52 of file TupleTest.cc.

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

Reimplemented from PLearn::PTest.

Definition at line 52 of file TupleTest.cc.

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

Reimplemented from PLearn::PTest.

Definition at line 52 of file TupleTest.cc.

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

Reimplemented from PLearn::PTest.

Definition at line 52 of file TupleTest.cc.

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

Reimplemented from PLearn::PTest.

Definition at line 52 of file TupleTest.cc.

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

Reimplemented from PLearn::PTest.

Definition at line 52 of file TupleTest.cc.

void PLearn::TupleTest::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 64 of file TupleTest.cc.

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

This does the actual building.

Reimplemented from PLearn::PTest.

Definition at line 99 of file TupleTest.cc.

{}
string PLearn::TupleTest::classname ( ) const [virtual]

Reimplemented from PLearn::PTest.

Definition at line 52 of file TupleTest.cc.

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

Declares the class options.

Reimplemented from PLearn::PTest.

Definition at line 90 of file TupleTest.cc.

{
    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}
static const PPath& PLearn::TupleTest::declaringFile ( ) [inline, static]

Reimplemented from PLearn::PTest.

Definition at line 84 of file TupleTest.h.

:
    //#####  Protected Options  ###############################################
TupleTest * PLearn::TupleTest::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::PTest.

Definition at line 52 of file TupleTest.cc.

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

Reimplemented from PLearn::PTest.

Definition at line 52 of file TupleTest.cc.

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

Reimplemented from PLearn::PTest.

Definition at line 52 of file TupleTest.cc.

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

Reimplemented from PLearn::PTest.

Definition at line 52 of file TupleTest.cc.

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

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::PTest.

Definition at line 73 of file TupleTest.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("TupleTest::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}
void PLearn::TupleTest::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 105 of file TupleTest.cc.

References PLearn::endl(), m, PLearn::openString(), PLearn::PStream::plearn_ascii, PLearn::PStream::plearn_binary, PLearn::pout, and PLearn::tostring().

{
    string srepr;
    PStream fromsrepr;

    // first test pair
    
    pout << "\n***** Simple pair test *****" << endl;
    
    typedef pair<string, pair<int, string> > p1_t;
    p1_t p1("mot1",make_pair(3,string("mot2")));
    pout << "Type: " << TypeTraits<p1_t>::name() << endl;
    pout << "Value: " << p1 << endl;

    srepr = tostring(p1,PStream::plearn_ascii);
    fromsrepr = openString(srepr, PStream::plearn_ascii);
    p1_t p1_fromascii;
    fromsrepr >> p1_fromascii;
    pout << "Value reread from plearn_ascii serialization: " << p1_fromascii << endl;
    pout << "Same? " << (p1_fromascii==p1) << endl;

    srepr = tostring(p1,PStream::plearn_binary);
    fromsrepr = openString(srepr, PStream::plearn_binary);
    p1_t p1_frombinary;
    fromsrepr >> p1_frombinary;
    pout << "Value reread from plearn_binary serialization: " << p1_frombinary << endl;
    pout << "Same? " << (p1_frombinary==p1) << endl;

    // test a simple tuple

    pout << "\n***** Simple tuple test *****" << endl;

    typedef tuple<int, double, string, char> t1_t;
    t1_t t1(3,4.5,string("essai"),'X');
    pout << "Type: " << TypeTraits<t1_t>::name() << endl;
    pout << "Value: " << t1 << endl;

    srepr = tostring(t1,PStream::plearn_ascii);
    fromsrepr = openString(srepr, PStream::plearn_ascii);
    t1_t t1_fromascii;
    fromsrepr >> t1_fromascii;
    pout << "Value reread from plearn_ascii serialization: " << t1_fromascii << endl;
    pout << "Same? " << (t1_fromascii==t1) << endl;

    srepr = tostring(t1,PStream::plearn_binary);
    fromsrepr = openString(srepr, PStream::plearn_binary);
    t1_t t1_frombinary;
    fromsrepr >> t1_frombinary;
    pout << "Value reread from plearn_binary serialization: " << t1_frombinary << endl;
    pout << "Same? " << (t1_frombinary==t1) << endl;

    // test a complex tuple

    pout << "\n***** Complex tuple test *****" << endl;

    typedef tuple<int, 
        float, 
        tuple<string, pair<double, int>, map<string, float> >,
        char> t2_t;
    map<string, float> m;
    m["key1"] = 1.0;
    m["key2"] = 2.0;
    m["key3"] = 3.0;
    t2_t t2(36, 
            3.25,
            make_tuple(string("mot1"), make_pair(4.5,3), m),
            'Z');
    pout << "Type: " << TypeTraits<t2_t>::name() << endl;
    pout << "Value: " << t2 << endl;

    srepr = tostring(t2,PStream::plearn_ascii);
    fromsrepr = openString(srepr, PStream::plearn_ascii);
    t2_t t2_fromascii;
    fromsrepr >> t2_fromascii;
    pout << "Value reread from plearn_ascii serialization: " << t2_fromascii << endl;
    pout << "Same? " << (t2_fromascii==t2) << endl;

    srepr = tostring(t2,PStream::plearn_binary);
    fromsrepr = openString(srepr, PStream::plearn_binary);
    t2_t t2_frombinary;
    fromsrepr >> t2_frombinary;
    pout << "Value reread from plearn_binary serialization: " << t2_frombinary << endl;
    pout << "Same? " << (t2_frombinary==t2) << endl;

    pout << "\n**** ALL DONE *****" << endl;
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::PTest.

Definition at line 84 of file TupleTest.h.


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