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

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

#include <TemporaryDiskVMatrix.h>

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

List of all members.

Public Member Functions

 TemporaryDiskVMatrix ()
 ### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
 TemporaryDiskVMatrix (const PPath &filename, bool writable=true, bool call_build_=true)
 Convenient constructor.
virtual ~TemporaryDiskVMatrix ()
 Destructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual TemporaryDiskVMatrixdeepCopy (CopiesMap &copies) const
virtual void build ()
 Simply calls inherited::build() then build_().
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.

Static Public Member Functions

static string _classname_ ()
 DiskVMatrix.
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_

Protected Member Functions

virtual void closeCurrentFiles ()
 Overridden to properly update the counter of references to open files.

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declares the class options.

Protected Attributes

TVec< PPathlast_files_opened
 A list of the files last opened by this VMatrix.
PPath last_dirname
 Last main directory opened by this VMatrix.

Private Types

typedef DiskVMatrix 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:
Synchronize this comment with the C++ built-in help.

Definition at line 59 of file TemporaryDiskVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::DiskVMatrix.

Definition at line 61 of file TemporaryDiskVMatrix.h.


Constructor & Destructor Documentation

PLearn::TemporaryDiskVMatrix::TemporaryDiskVMatrix ( )

### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!

Default constructor.

Definition at line 60 of file TemporaryDiskVMatrix.cc.

{}
PLearn::TemporaryDiskVMatrix::TemporaryDiskVMatrix ( const PPath filename,
bool  writable = true,
bool  call_build_ = true 
)

Convenient constructor.

Definition at line 63 of file TemporaryDiskVMatrix.cc.

References build_().

                                                                           :
    inherited(filename, writable, call_build_)
{
    if (call_build_)
        build_();
}

Here is the call graph for this function:

PLearn::TemporaryDiskVMatrix::~TemporaryDiskVMatrix ( ) [virtual]

Destructor.

Definition at line 138 of file TemporaryDiskVMatrix.cc.

References PLearn::PPath::absolute(), closeCurrentFiles(), PLearn::TVec< T >::copy(), PLearn::DiskVMatrix::dirname, PLearn::force_rmdir(), PLearn::VMatrix::getMetaDataDir(), PLearn::VMatrix::hasMetaDataDir(), i, last_dirname, last_files_opened, PLearn::TVec< T >::length(), PLearn::VMatrix::metadatadir, PLearn::noReferenceToFile(), PLERROR, and PLearn::rm().

{
    TVec<PPath> backup_files_opened = last_files_opened.copy();
    TemporaryDiskVMatrix::closeCurrentFiles();
    bool can_delete_whole_dir = true;
    bool one_file_deleted = false;
    for (int i = 0; i < backup_files_opened.length(); i++) {
        if (noReferenceToFile(backup_files_opened[i])) {
            rm(backup_files_opened[i]);
            one_file_deleted = true;
        } else
            can_delete_whole_dir = false;
    }
    if (one_file_deleted && !can_delete_whole_dir)
        PLERROR("In TemporaryDiskVMatrix::~TemporaryDiskVMatrix - Some data "
                "file has been deleted, but not all of them: something must "
                "be wrong");
    if (can_delete_whole_dir && !noReferenceToFile(dirname))
        PLERROR("In TemporaryDiskVMatrix::~TemporaryDiskVMatrix - Was able to "
                "delete all files in '%s', but it looks like someone is still "
                "using this directory: something must be wrong",
                dirname.absolute().c_str());
    if (!can_delete_whole_dir && noReferenceToFile(dirname))
        PLERROR("In TemporaryDiskVMatrix::~TemporaryDiskVMatrix - Directory "
                "'%s' is said to have noone referencing it, however it looks "
                "like some files in the directory are still being used: this "
                "should not happen",
                dirname.absolute().c_str());
    if (can_delete_whole_dir) {
        force_rmdir(last_dirname);
        if (hasMetaDataDir()) {
            force_rmdir(getMetaDataDir());
            // Clear the metadatadir so that the parent class does not try to
            // do anything with it.
            metadatadir = "";
        }
    }
}

Here is the call graph for this function:


Member Function Documentation

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

DiskVMatrix.

Reimplemented from PLearn::DiskVMatrix.

Definition at line 55 of file TemporaryDiskVMatrix.cc.

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

Reimplemented from PLearn::DiskVMatrix.

Definition at line 55 of file TemporaryDiskVMatrix.cc.

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

Reimplemented from PLearn::DiskVMatrix.

Definition at line 55 of file TemporaryDiskVMatrix.cc.

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

Reimplemented from PLearn::DiskVMatrix.

Definition at line 55 of file TemporaryDiskVMatrix.cc.

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

Reimplemented from PLearn::DiskVMatrix.

Definition at line 55 of file TemporaryDiskVMatrix.cc.

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

Reimplemented from PLearn::DiskVMatrix.

Definition at line 55 of file TemporaryDiskVMatrix.cc.

void PLearn::TemporaryDiskVMatrix::build ( ) [virtual]

Simply calls inherited::build() then build_().

Reimplemented from PLearn::DiskVMatrix.

Definition at line 83 of file TemporaryDiskVMatrix.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::DiskVMatrix.

Definition at line 92 of file TemporaryDiskVMatrix.cc.

References PLearn::addReferenceToFile(), PLearn::TVec< T >::append(), PLearn::DiskVMatrix::dataf, PLearn::DiskVMatrix::dirname, i, PLearn::DiskVMatrix::indexf, last_dirname, last_files_opened, PLearn::TVec< T >::length(), PLearn::TVec< T >::resize(), PLearn::tostring(), and PLearn::VMatrix::updateMtime().

Referenced by build(), and TemporaryDiskVMatrix().

{
    last_files_opened.resize(0);
    last_dirname = dirname;
    addReferenceToFile(dirname);
    if (indexf)
        last_files_opened.append(dirname / "indexfile");
    updateMtime(dirname/"indexfile");
    for (int i = 0; i < dataf.length(); i++)
        if (dataf[i])
            last_files_opened.append(dirname / (tostring(i) + ".data"));
    for (int i = 0; i < last_files_opened.length(); i++)
        addReferenceToFile(last_files_opened[i]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::DiskVMatrix.

Definition at line 55 of file TemporaryDiskVMatrix.cc.

void PLearn::TemporaryDiskVMatrix::closeCurrentFiles ( ) [protected, virtual]

Overridden to properly update the counter of references to open files.

Reimplemented from PLearn::DiskVMatrix.

Definition at line 110 of file TemporaryDiskVMatrix.cc.

References PLearn::DiskVMatrix::closeCurrentFiles(), i, last_dirname, last_files_opened, PLearn::TVec< T >::length(), PLearn::removeReferenceToFile(), and PLearn::TVec< T >::resize().

Referenced by ~TemporaryDiskVMatrix().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Declares the class options.

Reimplemented from PLearn::DiskVMatrix.

Definition at line 74 of file TemporaryDiskVMatrix.cc.

References PLearn::DiskVMatrix::declareOptions().

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

Here is the call graph for this function:

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

Reimplemented from PLearn::DiskVMatrix.

Definition at line 85 of file TemporaryDiskVMatrix.h.

:

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

Reimplemented from PLearn::DiskVMatrix.

Definition at line 55 of file TemporaryDiskVMatrix.cc.

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

Reimplemented from PLearn::DiskVMatrix.

Definition at line 55 of file TemporaryDiskVMatrix.cc.

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

Reimplemented from PLearn::DiskVMatrix.

Definition at line 55 of file TemporaryDiskVMatrix.cc.

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

Reimplemented from PLearn::DiskVMatrix.

Definition at line 55 of file TemporaryDiskVMatrix.cc.

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

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::DiskVMatrix.

Definition at line 122 of file TemporaryDiskVMatrix.cc.

References PLearn::deepCopyField(), last_dirname, last_files_opened, PLearn::DiskVMatrix::makeDeepCopyFromShallowCopy(), and PLearn::TVec< T >::resize().

{
    deepCopyField(last_files_opened, copies);
    // Clearing 'last_files_opened' is important: no file has been opened yet
    // by this VMat, as file pointers need to be recreated (this will be done
    // in inherited::makeDeepCopyFromShallowCopy(..)).
    // Similarly, 'last_dirname' needs to be cleared since it has not actually
    // been opened yet by this VMat.
    last_files_opened.resize(0);
    last_dirname = "";
    inherited::makeDeepCopyFromShallowCopy(copies);
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::DiskVMatrix.

Definition at line 85 of file TemporaryDiskVMatrix.h.

Last main directory opened by this VMatrix.

Definition at line 99 of file TemporaryDiskVMatrix.h.

Referenced by build_(), closeCurrentFiles(), makeDeepCopyFromShallowCopy(), and ~TemporaryDiskVMatrix().

A list of the files last opened by this VMatrix.

Definition at line 96 of file TemporaryDiskVMatrix.h.

Referenced by build_(), closeCurrentFiles(), makeDeepCopyFromShallowCopy(), and ~TemporaryDiskVMatrix().


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