All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Public Member Functions | List of all members
simdb::Client Class Reference

API for external clients. This class provides a client-side API for the SimDB system. It provides functions that a generic C++ program can use to comunicate as a client with a SimDB server. More...

#include <Client.h>

Public Member Functions

bool insertDataSet (const std::string &dssName, std::map< std::string, std::string > &sdFields, const std::map< std::string, std::string > &dataItems)
 
bool removeDataSet (const std::string &sequenceNumber, const std::string &dssName)
 
bool getDataSet (const std::string &sequenceNumber, const std::string &dssName)
 
bool searchDataSet (const std::string &dssName, std::map< std::string, std::string > &sdQueryFields)
 
bool listDss ()
 
bool sendExtendedCommand (const std::string &command)
 
void setServerAddress (const std::string &address)
 
bool setServerPort (const std::string &port)
 
void setDataDirectory (const std::string &dataDir)
 

Detailed Description

API for external clients. This class provides a client-side API for the SimDB system. It provides functions that a generic C++ program can use to comunicate as a client with a SimDB server.

Member Function Documentation

bool simdb::Client::getDataSet ( const std::string &  sequenceNumber,
const std::string &  dssName 
)

Send a GET command to the server. The received data is saved in the data directory.

Parameters
sequenceNumberThe SN of the DataSet to be retrieved.
dssNameThe DSS name in the command.
Returns
true if the operation succeeds, false otherwise.
bool simdb::Client::insertDataSet ( const std::string &  dssName,
std::map< std::string, std::string > &  sdFields,
const std::map< std::string, std::string > &  dataItems 
)

Send an INSERT command to the server.

Parameters
dssNameThe DSS name in the command.
sdFieldsThe list of SetDescriptor fields, as a <key, value> map.
dataItemsThe list of DataItems and their instance files, as an <item, instance> map.
Returns
true if the operation succeeds, false otherwise.
bool Client::listDss ( )

Send a SPECLIST command to the server.

Returns
true if the operation succeeds, false otherwise.
bool simdb::Client::removeDataSet ( const std::string &  sequenceNumber,
const std::string &  dssName 
)

Send a REMOVE command to the server.

Parameters
sequenceNumberThe SN of the DataSet to be removed.
dssNameThe DSS name in the command.
Returns
true if the operation succeeds, false otherwise.
bool simdb::Client::searchDataSet ( const std::string &  dssName,
std::map< std::string, std::string > &  sdQueryFields 
)

Send a SEARCH command to the server.

Parameters
dssNameThe DSS name in the command.
sdQueryFieldsThe list of SetDescriptor fields in the query, as a <key, value> map. It can be empty.
Returns
true if the operation succeeds, false otherwise.
bool Client::sendExtendedCommand ( const std::string &  command)

Send an extended command to the server. The command is parsed to understand its type.

Parameters
commandsThe string with the command message to be sent.
Returns
true if the operation succeeds, false otherwise.
void Client::setDataDirectory ( const std::string &  dataDir)

Set a custom data directory different from the default one. If the given directory doesn't exists it is created.

Parameters
dataDirAn absolute directory path.
void Client::setServerAddress ( const std::string &  address)

Set a custom server address different from the default one.

Parameters
addressA custom IPv4 server address in the "dotted" format (e.g. "192.168.0.1").
bool Client::setServerPort ( const std::string &  port)

Set a custom server port different from the default one. The given string is converted into an unsigned short.

Parameters
portA custom server port; it must be an integer greather than 1024, while integers greather than 65535 are treated as 65535.
Returns
true if the port is valid, false otherwise.

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