QDP++
QDP::MapObjectDisk< K, V > Class Template Reference

A wrapper over maps. More...

#include <qdp_map_obj_disk.h>

Inheritance diagram for QDP::MapObjectDisk< K, V >:
QDP::MapObject< K, V >

Public Types

typedef std::iostream::pos_type pos_type
typedef std::iostream::off_type off_type

Public Member Functions

 MapObjectDisk ()
 Empty constructor.
 ~MapObjectDisk ()
 Finalizes object.
void setDebug (int level)
 Set debugging level.
int getDebug () const
 Get debugging level.
void open (const std::string &file, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out)
 Open a file.
bool fileExists (const std::string &file) const
 Check if a DB file exists before opening.
void close ()
 Close the file.
int insert (const K &key, const V &val)
int get (const K &key, V &val) const
void flush ()
 Destructor.
bool exist (const K &key) const
unsigned int size () const
void keys (std::vector< K > &keys_) const
 Dump keys.
int insertUserdata (const std::string &user_data)
int getUserdata (std::string &user_data) const
Public Member Functions inherited from QDP::MapObject< K, V >
virtual ~MapObject ()
 Virtual Destructor.

Detailed Description

template<typename K, typename V>
class QDP::MapObjectDisk< K, V >

A wrapper over maps.

Definition at line 36 of file qdp_map_obj_disk.h.

Member Typedef Documentation

◆ off_type

template<typename K, typename V>
typedef std::iostream::off_type QDP::MapObjectDisk< K, V >::off_type

Definition at line 123 of file qdp_map_obj_disk.h.

◆ pos_type

template<typename K, typename V>
typedef std::iostream::pos_type QDP::MapObjectDisk< K, V >::pos_type

Definition at line 122 of file qdp_map_obj_disk.h.

Constructor & Destructor Documentation

◆ MapObjectDisk()

template<typename K, typename V>
QDP::MapObjectDisk< K, V >::MapObjectDisk ( )
inline

Empty constructor.

Definition at line 40 of file qdp_map_obj_disk.h.

◆ ~MapObjectDisk()

template<typename K, typename V>
QDP::MapObjectDisk< K, V >::~MapObjectDisk ( )

Finalizes object.

Destructor.

Definition at line 431 of file qdp_map_obj_disk.h.

References QDP::close().

Member Function Documentation

◆ close()

template<typename K, typename V>
void QDP::MapObjectDisk< K, V >::close ( )

Close the file.

Close.

Definition at line 404 of file qdp_map_obj_disk.h.

◆ exist()

template<typename K, typename V>
bool QDP::MapObjectDisk< K, V >::exist ( const K & key) const
virtual

Does this key exist in the store

Parameters
keya key object
Returns
true if the answer is yes

Implements QDP::MapObject< K, V >.

Definition at line 733 of file qdp_map_obj_disk.h.

References QDP::BinaryBufferWriter::str(), and QDP::write().

◆ fileExists()

template<typename K, typename V>
bool QDP::MapObjectDisk< K, V >::fileExists ( const std::string & file) const
inline

Check if a DB file exists before opening.

Definition at line 55 of file qdp_map_obj_disk.h.

References QDP::MapObjDiskEnv::checkForNewFile().

◆ flush()

template<typename K, typename V>
void QDP::MapObjectDisk< K, V >::flush ( )
virtual

Destructor.

Flush database in memory to disk

Implements QDP::MapObject< K, V >.

Definition at line 440 of file qdp_map_obj_disk.h.

◆ get()

template<typename K, typename V>
int QDP::MapObjectDisk< K, V >::get ( const K & key,
V & val ) const
virtual

Get data for a given key

Parameters
keyuser supplied key
dataafter the call data will be populated
Returns
0 on success, otherwise the key not found

Lookup an item in the map.

Implements QDP::MapObject< K, V >.

Definition at line 642 of file qdp_map_obj_disk.h.

References QDP::QDPIO::cout, QDP::StopWatch::getTimeInSeconds(), QDP::QDP_abort(), QDP::read(), QDP::StopWatch::reset(), QDP::StopWatch::start(), QDP::StopWatch::stop(), QDP::BinaryBufferWriter::str(), and QDP::write().

◆ getDebug()

template<typename K, typename V>
int QDP::MapObjectDisk< K, V >::getDebug ( ) const
inline

Get debugging level.

Definition at line 49 of file qdp_map_obj_disk.h.

◆ getUserdata()

template<typename K, typename V>
int QDP::MapObjectDisk< K, V >::getUserdata ( std::string & _user_data) const
virtual

Get user user data from the metadata database

Parameters
user_datauser supplied buffer to store user data
Returns
returns 0 if success. Otherwise failure.

Implements QDP::MapObject< K, V >.

Definition at line 513 of file qdp_map_obj_disk.h.

◆ insert()

template<typename K, typename V>
int QDP::MapObjectDisk< K, V >::insert ( const K & key,
const V & val )
virtual

Insert a pair of data and key into the database

Parameters
keya key
vala user provided data
Returns
0 on successful write, -1 on failure with proper errno set

Insert a value into the Map.

Implements QDP::MapObject< K, V >.

Definition at line 543 of file qdp_map_obj_disk.h.

References QDP::QDPIO::cout, QDP::StopWatch::getTimeInSeconds(), QDP::StopWatch::reset(), QDP::StopWatch::start(), QDP::StopWatch::stop(), QDP::BinaryBufferWriter::str(), and QDP::write().

◆ insertUserdata()

template<typename K, typename V>
int QDP::MapObjectDisk< K, V >::insertUserdata ( const std::string & _user_data)
virtual

Insert user data into the metadata database

Parameters
user_datauser supplied data
Returns
returns 0 if success, else failure

Insert user data into the metadata database

Implements QDP::MapObject< K, V >.

Definition at line 483 of file qdp_map_obj_disk.h.

◆ keys()

template<typename K, typename V>
void QDP::MapObjectDisk< K, V >::keys ( std::vector< K > & keys_) const
virtual

Dump keys.

Return all available keys to user

Parameters
keysuser suppled an empty vector which is populated by keys after this call.

Implements QDP::MapObject< K, V >.

Definition at line 460 of file qdp_map_obj_disk.h.

References QDP::read().

◆ open()

template<typename K, typename V>
void QDP::MapObjectDisk< K, V >::open ( const std::string & file,
std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out )

Open a file.

Definition at line 237 of file qdp_map_obj_disk.h.

References QDP::MapObjDiskEnv::checkForNewFile().

◆ setDebug()

template<typename K, typename V>
void QDP::MapObjectDisk< K, V >::setDebug ( int level)

Set debugging level.

Definition at line 202 of file qdp_map_obj_disk.h.

◆ size()

template<typename K, typename V>
unsigned int QDP::MapObjectDisk< K, V >::size ( ) const
inlinevirtual

The number of elements

Implements QDP::MapObject< K, V >.

Definition at line 96 of file qdp_map_obj_disk.h.


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