Classes | Public Member Functions | Private Types | Private Attributes

Repository Class Reference

The Repository of DataSets. More...

#include <keyvalue/mngt/Repository.h>

List of all members.

Classes

class  NotFound
 Exception thrown by get() when a DataSet is not found. More...

Public Member Functions

void add (shared_ptr< DataSet > dataSet)
 Inserts a DataSet to Repository.
bool erase (const string &name)
 Erases a DataSet from Repository.
size_t clear ()
 Erases all DataSets from Repository.
shared_ptr< DataSetfind (const string &name) const
 Gets a DataSet stored in the Repository.
shared_ptr< DataSetgetDataSet (const string &name) const
 Gets a DataSet stored in the Repository.
size_t getSize () const
 Gets the current number of stored DataSets.
value::Vector getList () const
 Gets the list of all stored DataSets.

Private Types

typedef std::map< string,
shared_ptr< DataSet > > 
Map_
typedef Map_::value_type Pair_

Private Attributes

Map_ map_

Detailed Description

The Repository of DataSets.

Use util::Global to access the global Repository.


Member Function Documentation

void add ( shared_ptr< DataSet dataSet  ) 

Inserts a DataSet to Repository.

If a DataSet with the same name already exists in the repository, then it will be destroyed and replaced by the new one.

If the DataSet name starts with '#', then nothing will be done.

Debug build asserts that name is not empty. Relase build has undefined behavior in this circumstance.

Parameters:
dataSet : Pointer to the DataSet to be inserted.
Exceptions:
LogicError : (Debug build only) If DataSet name is empty.
bool erase ( const string &  name  ) 

Erases a DataSet from Repository.

Parameters:
name : The name of DataSet to be erased.
Returns:
This method returns true if the DataSet was found and erased. Otherwise it returns false.
size_t clear (  ) 

Erases all DataSets from Repository.

Returns:
The number of DataSets erased.
shared_ptr<DataSet> find ( const string &  name  )  const

Gets a DataSet stored in the Repository.

Parameters:
name : The name of the required DataSet.
Returns:
If DataSet is fond, then this method returns a pointer to it. Otherwise, it returns a null pointer.
shared_ptr<DataSet> getDataSet ( const string &  name  )  const

Gets a DataSet stored in the Repository.

Parameters:
name : The name of the required DataSet.
Exceptions:
NotFound : If DataSet name is not found.
Returns:
A pointer to the DataSet.
size_t getSize (  )  const

Gets the current number of stored DataSets.

Returns:
The number of stored DataSets.
value::Vector getList (  )  const

Gets the list of all stored DataSets.

Returns:
A vector with names of stored DataSets.