2012-05-17 18:45:48 -04:00
|
|
|
#ifndef RSDATASERVICE_H
|
|
|
|
#define RSDATASERVICE_H
|
|
|
|
|
2012-07-12 16:18:58 -04:00
|
|
|
#include "gxs/rsgds.h"
|
2012-05-17 18:45:48 -04:00
|
|
|
|
|
|
|
#include "util/retrodb.h"
|
|
|
|
|
|
|
|
class RsDataService : public RsGeneralDataService
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
RsDataService(const std::string& serviceDir, const std::string& dbName, uint16_t serviceType, RsGxsSearchModule* mod = NULL);
|
2012-05-17 18:45:48 -04:00
|
|
|
virtual ~RsDataService();
|
|
|
|
|
|
|
|
/*!
|
2012-06-26 15:52:01 -04:00
|
|
|
* Retrieves all msgs
|
|
|
|
* @param reqIds requested msg ids (grpId,msgId), leave msg list empty to get all msgs for the grp
|
2012-05-17 18:45:48 -04:00
|
|
|
* @param msg result of msg retrieval
|
2012-06-26 15:52:01 -04:00
|
|
|
* @param cache whether to store results of this retrieval in memory for faster later retrieval
|
2012-05-17 18:45:48 -04:00
|
|
|
* @return error code
|
|
|
|
*/
|
2012-06-26 15:52:01 -04:00
|
|
|
int retrieveNxsMsgs(const GxsMsgReq& reqIds, GxsMsgResult& msg, bool cache);
|
2012-05-17 18:45:48 -04:00
|
|
|
|
|
|
|
/*!
|
2012-06-26 15:52:01 -04:00
|
|
|
* Retrieves all groups stored (most current versions only)
|
|
|
|
* @param grp retrieved groups
|
2012-05-17 18:45:48 -04:00
|
|
|
* @param cache whether to store retrieval in mem for faster later retrieval
|
|
|
|
* @return error code
|
|
|
|
*/
|
2012-06-26 15:52:01 -04:00
|
|
|
int retrieveNxsGrps(std::map<std::string, RsNxsGrp*>& grp, bool cache);
|
2012-05-17 18:45:48 -04:00
|
|
|
|
|
|
|
/*!
|
2012-06-26 15:52:01 -04:00
|
|
|
* Retrieves meta data of all groups stored (most current versions only)
|
|
|
|
* @param cache whether to store retrieval in mem for faster later retrieval
|
|
|
|
* @return error code
|
2012-05-17 18:45:48 -04:00
|
|
|
*/
|
2012-06-26 15:52:01 -04:00
|
|
|
int retrieveGxsGrpMetaData(std::map<std::string, RsGxsGrpMetaData*>& grp);
|
2012-05-17 18:45:48 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
/*!
|
2012-06-26 15:52:01 -04:00
|
|
|
* Retrieves meta data of all groups stored (most current versions only)
|
|
|
|
* @param grpIds grpIds for which to retrieve meta data
|
|
|
|
* @param msgMeta meta data result as map of grpIds to array of metadata for that grpId
|
|
|
|
* @param cache whether to store retrieval in mem for faster later retrieval
|
|
|
|
* @return error code
|
2012-05-21 18:07:43 -04:00
|
|
|
*/
|
2012-06-26 15:52:01 -04:00
|
|
|
int retrieveGxsMsgMetaData(const std::vector<std::string>& grpIds, GxsMsgMetaResult& msgMeta);
|
2012-05-17 18:45:48 -04:00
|
|
|
|
2012-06-03 14:09:38 -04:00
|
|
|
/*!
|
2012-06-26 15:52:01 -04:00
|
|
|
* remove msgs in data store
|
|
|
|
* @param grpId group Id of message to be removed
|
2012-06-03 14:09:38 -04:00
|
|
|
* @param msgIds ids of messages to be removed
|
|
|
|
* @return error code
|
|
|
|
*/
|
2012-06-26 15:52:01 -04:00
|
|
|
int removeMsgs(const std::string grpId, const std::vector<std::string>& msgIds);
|
2012-06-03 14:09:38 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* remove groups in data store listed in grpIds param
|
|
|
|
* @param grpIds ids of groups to be removed
|
|
|
|
* @return error code
|
|
|
|
*/
|
2012-06-26 15:52:01 -04:00
|
|
|
int removeGroups(const std::vector<std::string>& grpIds);
|
2012-06-03 14:09:38 -04:00
|
|
|
|
2012-05-17 18:45:48 -04:00
|
|
|
/*!
|
2012-06-26 15:52:01 -04:00
|
|
|
* @return the cache size set for this RsGeneralDataService in bytes
|
2012-05-17 18:45:48 -04:00
|
|
|
*/
|
2012-06-26 15:52:01 -04:00
|
|
|
uint32_t cacheSize() const;
|
2012-05-17 18:45:48 -04:00
|
|
|
|
|
|
|
/*!
|
2012-06-26 15:52:01 -04:00
|
|
|
* @param size size of cache to set in bytes
|
2012-05-17 18:45:48 -04:00
|
|
|
*/
|
2012-06-26 15:52:01 -04:00
|
|
|
int setCacheSize(uint32_t size);
|
2012-05-17 18:45:48 -04:00
|
|
|
|
|
|
|
/*!
|
2012-06-26 15:52:01 -04:00
|
|
|
* Stores a list of signed messages into data store
|
|
|
|
* @param msg map of message and decoded meta data information
|
|
|
|
* @return error code
|
2012-05-17 18:45:48 -04:00
|
|
|
*/
|
2012-06-26 15:52:01 -04:00
|
|
|
int storeMessage(std::map<RsNxsMsg*, RsGxsMsgMetaData*>& msg);
|
2012-05-17 18:45:48 -04:00
|
|
|
|
2012-05-21 18:07:43 -04:00
|
|
|
/*!
|
2012-06-26 15:52:01 -04:00
|
|
|
* Stores a list of groups in data store
|
|
|
|
* @param grp map of group and decoded meta data
|
|
|
|
* @return error code
|
2012-05-21 18:07:43 -04:00
|
|
|
*/
|
2012-06-26 15:52:01 -04:00
|
|
|
int storeGroup(std::map<RsNxsGrp*, RsGxsGrpMetaData*>& grp);
|
2012-05-17 18:45:48 -04:00
|
|
|
|
|
|
|
/*!
|
2012-06-26 15:52:01 -04:00
|
|
|
* @param metaData The meta data item to update
|
2012-05-17 18:45:48 -04:00
|
|
|
* @return error code
|
|
|
|
*/
|
2012-06-26 15:52:01 -04:00
|
|
|
int updateMessageMetaData(MsgLocMetaData* metaData);
|
2012-05-17 18:45:48 -04:00
|
|
|
|
|
|
|
/*!
|
2012-06-26 15:52:01 -04:00
|
|
|
* @param metaData The meta data item to update
|
2012-05-17 18:45:48 -04:00
|
|
|
* @return error code
|
|
|
|
*/
|
2012-06-26 15:52:01 -04:00
|
|
|
int updateGroupMetaData(GrpLocMetaData* meta);
|
|
|
|
|
2012-05-17 18:45:48 -04:00
|
|
|
|
2012-06-03 14:09:38 -04:00
|
|
|
/*!
|
|
|
|
* Completely clear out data stored in
|
2012-06-26 15:52:01 -04:00
|
|
|
* and returns this to a state
|
2012-06-03 14:09:38 -04:00
|
|
|
* as it was when first constructed
|
2012-06-26 15:52:01 -04:00
|
|
|
* @return error code
|
2012-06-03 14:09:38 -04:00
|
|
|
*/
|
|
|
|
int resetDataStore();
|
|
|
|
|
2012-05-17 18:45:48 -04:00
|
|
|
private:
|
|
|
|
|
2012-06-26 15:52:01 -04:00
|
|
|
/*!
|
|
|
|
* Retrieves all the msg results from a cursor
|
|
|
|
* @param c cursor to result set
|
|
|
|
* @param msgs messages retrieved from cursor are stored here
|
|
|
|
*/
|
|
|
|
void retrieveMessages(RetroCursor* c, std::vector<RsNxsMsg*>& msgs);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* extracts a msg meta item from a cursor at its
|
|
|
|
* current position
|
|
|
|
*/
|
|
|
|
RsGxsMsgMetaData* getMsgMeta(RetroCursor& c);
|
2012-05-17 18:45:48 -04:00
|
|
|
|
2012-06-26 15:52:01 -04:00
|
|
|
/*!
|
|
|
|
* extracts a grp meta item from a cursor at its
|
|
|
|
* current position
|
|
|
|
*/
|
|
|
|
RsGxsGrpMetaData* getGrpMeta(RetroCursor& c);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* extracts a msg item from a cursor at its
|
|
|
|
* current position
|
|
|
|
*/
|
2012-05-17 18:45:48 -04:00
|
|
|
RsNxsMsg* getMessage(RetroCursor& c);
|
2012-06-26 15:52:01 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* extracts a grp item from a cursor at its
|
|
|
|
* current position
|
|
|
|
*/
|
2012-05-17 18:45:48 -04:00
|
|
|
RsNxsGrp* getGroup(RetroCursor& c);
|
2012-06-26 15:52:01 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Creates an sql database and its associated file
|
|
|
|
* also creates the message and groups table
|
|
|
|
*/
|
2012-06-05 10:46:18 -04:00
|
|
|
void initialise();
|
2012-05-17 18:45:48 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
RetroDb* mDb;
|
2012-06-26 15:52:01 -04:00
|
|
|
|
2012-05-17 18:45:48 -04:00
|
|
|
std::list<std::string> msgColumns;
|
2012-06-26 15:52:01 -04:00
|
|
|
std::list<std::string> msgMetaColumns;
|
|
|
|
|
2012-05-17 18:45:48 -04:00
|
|
|
std::list<std::string> grpColumns;
|
2012-06-26 15:52:01 -04:00
|
|
|
std::list<std::string> grpMetaColumns;
|
2012-05-21 18:07:43 -04:00
|
|
|
|
|
|
|
std::string mServiceDir, mDbName;
|
|
|
|
uint16_t mServType;
|
2012-05-17 18:45:48 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RSDATASERVICE_H
|