PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <TemporaryDiskVMatrix.h>
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 OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual TemporaryDiskVMatrix * | deepCopy (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 PPath & | declaringFile () |
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< PPath > | last_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. |
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
Definition at line 59 of file TemporaryDiskVMatrix.h.
typedef DiskVMatrix PLearn::TemporaryDiskVMatrix::inherited [private] |
Reimplemented from PLearn::DiskVMatrix.
Definition at line 61 of file TemporaryDiskVMatrix.h.
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_().
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 = ""; } } }
string PLearn::TemporaryDiskVMatrix::_classname_ | ( | ) | [static] |
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.
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_().
{ inherited::build(); build_(); }
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]); }
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().
{ inherited::closeCurrentFiles(); for (int i = 0; i < last_files_opened.length(); i++) removeReferenceToFile(last_files_opened[i]); removeReferenceToFile(last_dirname); last_files_opened.resize(0); }
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); }
static const PPath& PLearn::TemporaryDiskVMatrix::declaringFile | ( | ) | [inline, static] |
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); }
Reimplemented from PLearn::DiskVMatrix.
Definition at line 85 of file TemporaryDiskVMatrix.h.
PPath PLearn::TemporaryDiskVMatrix::last_dirname [protected] |
Last main directory opened by this VMatrix.
Definition at line 99 of file TemporaryDiskVMatrix.h.
Referenced by build_(), closeCurrentFiles(), makeDeepCopyFromShallowCopy(), and ~TemporaryDiskVMatrix().
TVec<PPath> PLearn::TemporaryDiskVMatrix::last_files_opened [protected] |
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().