EasyCV  0.9.36
Easy! Computer Vision
Public Member Functions | Private Attributes | List of all members
cvac::DetectorDataArchive Class Reference

#include <DetectorDataArchive.h>

Public Member Functions

 DetectorDataArchive ()
 
void createArchive (const std::string &relDirectory)
 
void unarchive (const std::string &archiveFile, const std::string &dir)
 
void setProperty (const std::string &name, const std::string &value)
 
std::vector< std::string > getProperties ()
 
std::string getProperty (const std::string &name) const
 
void setArchiveFilename (std::string &filename)
 
bool addFile (const std::string &identifier, const std::string &filename)
 
bool removeFile (const std::string &identifier)
 
const std::vector< std::string > getFileIds ()
 
const std::string getFile (const std::string &identifier) const
 

Private Attributes

std::string mArchiveName
 
std::vector< std::string > mPropNames
 
std::vector< std::string > mPropValues
 
std::vector< std::string > mFileNames
 
std::vector< std::string > mFileIds
 

Constructor & Destructor Documentation

cvac::DetectorDataArchive::DetectorDataArchive ( )

Construct a DetectorDataArchive class

TODO:
The DetectorDataArchive implementation should be changed as follows.
Only one minor interface modification would result: DDA client would
need to make the distinction between keys that are references to files
and keys that are other properties.

Changes: use a std::map instead of two parallel vectors of keys and values. Make the key comparison operator perform a case-insensitive string comparison. Don't distinguish between a property and file in DDA; always use "=" as separator. Instead, provide a function that returns a full file path for a given key which a DDA client can call: getFSPathForProperty( const std::string& key ) Do not require the space before and after the = Chop the keys and values (remove leading and trailing whitespace) Write a unit test for DDA.

Member Function Documentation

bool cvac::DetectorDataArchive::addFile ( const std::string &  identifier,
const std::string &  filename 
)

Add a file to the archive. A file has two parts. An identifier string that tells what this file is and the name of the file itself. This assumes that it might not be possible to determine the purpose of the file just by given its name.

Parameters
identifier- the identifier string for the file
filename- the file name.
Returns
- returns true if the file exists and no other file in the archive has this identifier else it returns false.
void cvac::DetectorDataArchive::createArchive ( const std::string &  relDirectory)

Archive the detector data using relDirectory. This throws an exception if the archive cannot be created.

const std::string cvac::DetectorDataArchive::getFile ( const std::string &  identifier) const

Get a file name in the archive based on its identifier

Parameters
identifier- the identifier string for the file
Returns
- the filename in the archive that matches the identifier. The return string is empty if there is no match.
const std::vector< std::string > cvac::DetectorDataArchive::getFileIds ( )

Get the list of file identifiers in a archive.

Returns
a vector of file identifiers contained in the archive.
vector< string > cvac::DetectorDataArchive::getProperties ( )

Get the list of properties currently defined. These can be set from an archive file or from the user or both.

string cvac::DetectorDataArchive::getProperty ( const std::string &  name) const

Get a value of a trainer property value defined by name.

bool cvac::DetectorDataArchive::removeFile ( const std::string &  identifier)

Remove the file that maps to this identifier from the archive

Parameters
identifier- the file identifier and file to remove
Returns
- returns true if the identifier was removed false if the identifier was not in the archive.
void cvac::DetectorDataArchive::setArchiveFilename ( std::string &  filename)

Set the archive filename. This should be the complete path and filename.

void cvac::DetectorDataArchive::setProperty ( const std::string &  name,
const std::string &  value 
)

Save a property which is a name, value pair. When the trainer data is archived these attributes are written out to the archive.

void cvac::DetectorDataArchive::unarchive ( const std::string &  archiveFile,
const std::string &  dir 
)

Unarchive the passed in archive file into dir. This throws an exception of the file cannot be found or compressed. If any trainer.property file existed in the archive then this DetectorDataArchive's properties are set to the contents of that file.

Parameters
archiveFilethe file to unarchive.
dirWrite all unarchived files into this directory.

Member Data Documentation

std::string cvac::DetectorDataArchive::mArchiveName
private
std::vector<std::string> cvac::DetectorDataArchive::mFileIds
private
std::vector<std::string> cvac::DetectorDataArchive::mFileNames
private
std::vector<std::string> cvac::DetectorDataArchive::mPropNames
private
std::vector<std::string> cvac::DetectorDataArchive::mPropValues
private

The documentation for this class was generated from the following files: