2012-05-17 22:45:48 +00:00
|
|
|
#ifndef RSDATASERVICE_H
|
|
|
|
#define RSDATASERVICE_H
|
|
|
|
|
|
|
|
#include "rsgds.h"
|
|
|
|
|
|
|
|
#include "util/retrodb.h"
|
|
|
|
|
|
|
|
class RsDataService : public RsGeneralDataService
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-05-21 22:07:43 +00:00
|
|
|
RsDataService(const std::string& serviceDir, const std::string& dbName, uint16_t serviceType, RsGxsSearchModule* mod = NULL);
|
2012-05-17 22:45:48 +00:00
|
|
|
virtual ~RsDataService();
|
|
|
|
|
|
|
|
/*!
|
2012-05-21 22:07:43 +00:00
|
|
|
* Retrieves latest version of msgs for a service
|
2012-05-17 22:45:48 +00:00
|
|
|
* @param msgIds ids of messagesto retrieve
|
|
|
|
* @param msg result of msg retrieval
|
|
|
|
* @param cache whether to store retrieval in memory for faster later retrieval
|
|
|
|
* @return error code
|
|
|
|
*/
|
2012-05-24 22:38:59 +00:00
|
|
|
int retrieveMsgs(const std::string& grpId, std::map<std::string, RsNxsMsg*> msg, bool cache);
|
2012-05-17 22:45:48 +00:00
|
|
|
|
|
|
|
/*!
|
2012-05-21 22:07:43 +00:00
|
|
|
* Retrieves latest version of groups for a service
|
2012-05-17 22:45:48 +00:00
|
|
|
* @param grpId the Id of the groups to retrieve
|
|
|
|
* @param grp results of retrieval
|
|
|
|
* @param cache whether to store retrieval in mem for faster later retrieval
|
|
|
|
* @return error code
|
|
|
|
*/
|
2012-05-24 22:38:59 +00:00
|
|
|
int retrieveGrps(std::map<std::string, RsNxsGrp*>& grp, bool cache);
|
2012-05-17 22:45:48 +00:00
|
|
|
|
|
|
|
/*!
|
2012-05-21 22:07:43 +00:00
|
|
|
* Retrieves all the versions of a group
|
2012-05-17 22:45:48 +00:00
|
|
|
* @param grpId the id of the group to get versions for
|
|
|
|
* @param cache whether to store the result in memory
|
2012-05-21 22:07:43 +00:00
|
|
|
* @return errCode
|
2012-05-17 22:45:48 +00:00
|
|
|
*/
|
2012-05-21 22:07:43 +00:00
|
|
|
int retrieveGrpVersions(const std::string &grpId, std::set<RsNxsGrp *> &grp, bool cache);
|
2012-05-17 22:45:48 +00:00
|
|
|
|
|
|
|
/*!
|
2012-05-21 22:07:43 +00:00
|
|
|
* retrieves all the versions of a message for a group
|
|
|
|
* @param grpId the id of the group message belongs to
|
2012-05-17 22:45:48 +00:00
|
|
|
* @param msgId the id of the message to get versions for
|
2012-05-21 22:07:43 +00:00
|
|
|
* @return errCode
|
2012-05-17 22:45:48 +00:00
|
|
|
*/
|
2012-05-24 22:38:59 +00:00
|
|
|
int retrieveMsgVersions(const std::string &grpId, const std::string& msgId, std::set<RsNxsMsg *>& grp, bool cache);
|
2012-05-17 22:45:48 +00:00
|
|
|
|
2012-05-21 22:07:43 +00:00
|
|
|
/*!
|
|
|
|
* @param msgId the id of the message to retrieve
|
|
|
|
* @return NULL if message does not exist, or pointer to grp if found
|
|
|
|
*/
|
|
|
|
RsNxsMsg* retrieveMsgVersion(const RsGxsMsgId& msgId);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @param grpId the id of the group to retrieve
|
|
|
|
* @return NULL if group does not exist or pointer to grp if found
|
|
|
|
*/
|
|
|
|
RsNxsGrp* retrieveGrpVersion(const RsGxsGrpId& grpId);
|
2012-05-17 22:45:48 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* allows for more complex queries specific to the service
|
|
|
|
* @param search generally stores parameters needed for query
|
|
|
|
* @param msgId is set with msg ids which satisfy the gxs search
|
|
|
|
* @return error code
|
|
|
|
*/
|
|
|
|
int searchMsgs(RsGxsSearch* search, std::list<RsGxsSrchResMsgCtx*>& result);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* allows for more complex queries specific to the associated service
|
|
|
|
* @param search generally stores parameters needed for query
|
|
|
|
* @param msgId is set with msg ids which satisfy the gxs search
|
|
|
|
* @return error code
|
|
|
|
*/
|
|
|
|
int searchGrps(RsGxsSearch* search, std::list<RsGxsSrchResGrpCtx*>& result);
|
|
|
|
|
|
|
|
/*!
|
2012-05-21 22:07:43 +00:00
|
|
|
* @return the cache size set for this RsGeneralDataService in bytes
|
2012-05-17 22:45:48 +00:00
|
|
|
*/
|
|
|
|
uint32_t cacheSize() const;
|
|
|
|
|
2012-05-21 22:07:43 +00:00
|
|
|
/*!
|
|
|
|
* @param size size of cache to set in bytes
|
|
|
|
*/
|
|
|
|
virtual int setCacheSize(uint32_t size);
|
2012-05-17 22:45:48 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Stores a list signed messages into data store
|
|
|
|
* @param msg list of signed messages to store
|
|
|
|
* @return error code
|
|
|
|
*/
|
|
|
|
int storeMessage(std::set<RsNxsMsg*>& msg);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Stores a list of groups in data store
|
|
|
|
* @param msg list of messages
|
|
|
|
* @return error code
|
|
|
|
*/
|
|
|
|
int storeGroup(std::set<RsNxsGrp*>& grp);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
RsNxsMsg* getMessage(RetroCursor& c);
|
|
|
|
RsNxsGrp* getGroup(RetroCursor& c);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
RetroDb* mDb;
|
|
|
|
std::list<std::string> msgColumns;
|
|
|
|
std::list<std::string> grpColumns;
|
2012-05-21 22:07:43 +00:00
|
|
|
|
|
|
|
std::string mServiceDir, mDbName;
|
|
|
|
uint16_t mServType;
|
2012-05-17 22:45:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RSDATASERVICE_H
|