Code maintenance for Qt 5:

- Renamed CacheData to RsCacheData, MinGW-w64 has already a class with the same name

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6862 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2013-10-21 12:07:33 +00:00
parent ec08eba2c9
commit 5b6aa594c6
13 changed files with 116 additions and 116 deletions

View File

@ -47,7 +47,7 @@ bool operator<(const CachePair &a, const CachePair &b)
} }
std::ostream &operator<<(std::ostream &out, const CacheData &d) std::ostream &operator<<(std::ostream &out, const RsCacheData &d)
{ {
out << "[ p: " << d.pid << " id: <" << d.cid.type << "," << d.cid.subid; out << "[ p: " << d.pid << " id: <" << d.cid.type << "," << d.cid.subid;
out << "> #" << d.hash << " size: " << d.size; out << "> #" << d.hash << " size: " << d.size;
@ -86,13 +86,13 @@ void CacheSource::unlockData() const
} }
/* to be overloaded for inherited Classes */ /* to be overloaded for inherited Classes */
bool CacheSource::loadLocalCache(const CacheData &data) bool CacheSource::loadLocalCache(const RsCacheData &data)
{ {
return refreshCache(data); return refreshCache(data);
} }
/* control Caches available */ /* control Caches available */
bool CacheSource::refreshCache(const CacheData &data,const std::set<std::string>& destination_peers) bool CacheSource::refreshCache(const RsCacheData &data,const std::set<std::string>& destination_peers)
{ {
bool ret = false; bool ret = false;
{ {
@ -133,7 +133,7 @@ bool CacheSource::refreshCache(const CacheData &data,const std::set<std::string>
return ret; return ret;
} }
bool CacheSource::refreshCache(const CacheData &data) bool CacheSource::refreshCache(const RsCacheData &data)
{ {
bool ret = false; bool ret = false;
{ {
@ -179,7 +179,7 @@ bool CacheSource::refreshCache(const CacheData &data)
} }
// bool CacheSource::refreshCache(const CacheData &data) // bool CacheSource::refreshCache(const RsCacheData &data)
// { // {
// bool ret = false; // bool ret = false;
// { // {
@ -232,7 +232,7 @@ bool CacheSource::clearCache(CacheId id)
return ret; return ret;
} }
bool CacheSource::cachesAvailable(RsPeerId pid, std::map<CacheId, CacheData> &ids) bool CacheSource::cachesAvailable(RsPeerId pid, std::map<CacheId, RsCacheData> &ids)
{ {
if(!isPeerAcceptedAsCacheReceiver(pid)) if(!isPeerAcceptedAsCacheReceiver(pid))
return false ; return false ;
@ -253,7 +253,7 @@ bool CacheSource::cachesAvailable(RsPeerId pid, std::map<CacheId, CacheData>
} }
bool CacheSource::findCache(std::string hash, CacheData &data) const bool CacheSource::findCache(std::string hash, RsCacheData &data) const
{ {
lockData(); /* LOCK MUTEX */ lockData(); /* LOCK MUTEX */
@ -271,7 +271,7 @@ bool CacheSource::findCache(std::string hash, CacheData &data) const
if (!found) if (!found)
{ {
std::map<std::string, CacheData>::const_iterator oit; std::map<std::string, RsCacheData>::const_iterator oit;
oit = mOldCaches.find(hash); oit = mOldCaches.find(hash);
if (oit != mOldCaches.end()) if (oit != mOldCaches.end())
{ {
@ -357,9 +357,9 @@ void CacheStore::listCaches(std::ostream &out)
} }
/* look for stored data. using pic/cid in CacheData /* look for stored data. using pic/cid in RsCacheData
*/ */
bool CacheStore::getStoredCache(CacheData &data) bool CacheStore::getStoredCache(RsCacheData &data)
{ {
lockData(); /* LOCK MUTEX */ lockData(); /* LOCK MUTEX */
@ -370,7 +370,7 @@ bool CacheStore::getStoredCache(CacheData &data)
} }
bool CacheStore::locked_getStoredCache(CacheData &data) bool CacheStore::locked_getStoredCache(RsCacheData &data)
{ {
if (data.cid.type != getCacheType()) if (data.cid.type != getCacheType())
{ {
@ -410,7 +410,7 @@ bool CacheStore::locked_getStoredCache(CacheData &data)
bool CacheStore::getAllStoredCaches(std::list<CacheData> &data) bool CacheStore::getAllStoredCaches(std::list<RsCacheData> &data)
{ {
lockData(); /* LOCK MUTEX */ lockData(); /* LOCK MUTEX */
@ -437,7 +437,7 @@ bool CacheStore::getAllStoredCaches(std::list<CacheData> &data)
* determine the new name/path * determine the new name/path
* then request it. * then request it.
*/ */
void CacheStore::availableCache(const CacheData &data) void CacheStore::availableCache(const RsCacheData &data)
{ {
#ifdef CS_DEBUG #ifdef CS_DEBUG
std::cerr << "CacheStore::availableCache() :" << data << std::endl; std::cerr << "CacheStore::availableCache() :" << data << std::endl;
@ -463,7 +463,7 @@ void CacheStore::availableCache(const CacheData &data)
return; /* ignore it */ return; /* ignore it */
} }
CacheData rData = data; RsCacheData rData = data;
/* get new name */ /* get new name */
if (!nameCache(rData)) if (!nameCache(rData))
@ -482,7 +482,7 @@ void CacheStore::availableCache(const CacheData &data)
/* called when the download is completed ... updates internal data */ /* called when the download is completed ... updates internal data */
void CacheStore::downloadedCache(const CacheData &data) void CacheStore::downloadedCache(const RsCacheData &data)
{ {
#ifdef CS_DEBUG #ifdef CS_DEBUG
std::cerr << "CacheStore::downloadedCache() :" << data << std::endl; std::cerr << "CacheStore::downloadedCache() :" << data << std::endl;
@ -495,7 +495,7 @@ void CacheStore::downloadedCache(const CacheData &data)
} }
} }
/* called when the download is completed ... updates internal data */ /* called when the download is completed ... updates internal data */
void CacheStore::failedCache(const CacheData &data) void CacheStore::failedCache(const RsCacheData &data)
{ {
(void) data; (void) data;
#ifdef CS_DEBUG #ifdef CS_DEBUG
@ -507,14 +507,14 @@ void CacheStore::failedCache(const CacheData &data)
/* virtual function overloaded by cache implementor */ /* virtual function overloaded by cache implementor */
bool CacheStore::fetchCache(const CacheData &data) bool CacheStore::fetchCache(const RsCacheData &data)
{ {
/* should we fetch it? */ /* should we fetch it? */
#ifdef CS_DEBUG #ifdef CS_DEBUG
std::cerr << "CacheStore::fetchCache() tofetch?:" << data << std::endl; std::cerr << "CacheStore::fetchCache() tofetch?:" << data << std::endl;
#endif #endif
CacheData incache = data; RsCacheData incache = data;
lockData(); /* LOCK MUTEX */ lockData(); /* LOCK MUTEX */
@ -538,7 +538,7 @@ bool CacheStore::fetchCache(const CacheData &data)
} }
int CacheStore::nameCache(CacheData &data) int CacheStore::nameCache(RsCacheData &data)
{ {
/* name it... */ /* name it... */
lockData(); /* LOCK MUTEX */ lockData(); /* LOCK MUTEX */
@ -560,7 +560,7 @@ int CacheStore::nameCache(CacheData &data)
} }
int CacheStore::loadCache(const CacheData &data) int CacheStore::loadCache(const RsCacheData &data)
{ {
/* attempt to load -> dummy function */ /* attempt to load -> dummy function */
#ifdef CS_DEBUG #ifdef CS_DEBUG
@ -582,7 +582,7 @@ int CacheStore::loadCache(const CacheData &data)
* It doesn't lock itself -> to avoid race conditions * It doesn't lock itself -> to avoid race conditions
*/ */
void CacheStore::locked_storeCacheEntry(const CacheData &data) void CacheStore::locked_storeCacheEntry(const RsCacheData &data)
{ {
/* store what we loaded - overwriting if necessary */ /* store what we loaded - overwriting if necessary */
std::map<RsPeerId, CacheSet>::iterator pit; std::map<RsPeerId, CacheSet>::iterator pit;
@ -642,8 +642,8 @@ void CacheStrapper::statusChange(const std::list<pqipeer> &plist)
{ {
/* grab all the cache ids and add */ /* grab all the cache ids and add */
std::map<CacheId,CacheData> hashs; std::map<CacheId,RsCacheData> hashs;
std::map<CacheId,CacheData>::iterator cit; std::map<CacheId,RsCacheData>::iterator cit;
handleCacheQuery(it->id, hashs); handleCacheQuery(it->id, hashs);
@ -658,7 +658,7 @@ void CacheStrapper::statusChange(const std::list<pqipeer> &plist)
/**************** from pqimonclient ********************/ /**************** from pqimonclient ********************/
void CacheStrapper::refreshCache(const CacheData &data,const std::set<std::string>& destination_peers) void CacheStrapper::refreshCache(const RsCacheData &data,const std::set<std::string>& destination_peers)
{ {
/* we've received an update /* we've received an update
* send to all online peers + self intersected with online peers. * send to all online peers + self intersected with online peers.
@ -684,7 +684,7 @@ void CacheStrapper::refreshCache(const CacheData &data,const std::set<std::strin
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
} }
// void CacheStrapper::refreshCache(const CacheData &data) // void CacheStrapper::refreshCache(const RsCacheData &data)
// { // {
// /* we've received an update // /* we've received an update
// * send to all online peers + self // * send to all online peers + self
@ -707,14 +707,14 @@ void CacheStrapper::refreshCache(const CacheData &data,const std::set<std::strin
// IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ // IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
// } // }
void CacheStrapper::refreshCacheStore(const CacheData & /* data */ ) void CacheStrapper::refreshCacheStore(const RsCacheData & /* data */ )
{ {
/* indicate to save data */ /* indicate to save data */
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
} }
bool CacheStrapper::getCacheUpdates(std::list<std::pair<RsPeerId, CacheData> > &updates) bool CacheStrapper::getCacheUpdates(std::list<std::pair<RsPeerId, RsCacheData> > &updates)
{ {
RsStackMutex stack(csMtx); /******* LOCK STACK MUTEX *********/ RsStackMutex stack(csMtx); /******* LOCK STACK MUTEX *********/
updates = mCacheUpdates; updates = mCacheUpdates;
@ -726,7 +726,7 @@ bool CacheStrapper::getCacheUpdates(std::list<std::pair<RsPeerId, CacheData> > &
/* pass to correct CacheSet */ /* pass to correct CacheSet */
void CacheStrapper::recvCacheResponse(CacheData &data, time_t /* ts */) void CacheStrapper::recvCacheResponse(RsCacheData &data, time_t /* ts */)
{ {
/* find cache store */ /* find cache store */
std::map<uint16_t, CachePair>::iterator it2; std::map<uint16_t, CachePair>::iterator it2;
@ -762,7 +762,7 @@ bool CacheStrapper::sendCacheQuery(std::list<RsPeerId> &id, time_t ts)
#endif #endif
void CacheStrapper::handleCacheQuery(RsPeerId id, std::map<CacheId,CacheData> &hashs) void CacheStrapper::handleCacheQuery(RsPeerId id, std::map<CacheId,RsCacheData> &hashs)
{ {
/* basic version just iterates through .... /* basic version just iterates through ....
* more complex could decide who gets what! * more complex could decide who gets what!
@ -816,7 +816,7 @@ void CacheStrapper::listPeerStatus(std::ostream & /* out */)
} }
bool CacheStrapper::findCache(std::string hash, CacheData &data) const bool CacheStrapper::findCache(std::string hash, RsCacheData &data) const
{ {
/* can overwrite for more control! */ /* can overwrite for more control! */
std::map<uint16_t, CachePair>::const_iterator it; std::map<uint16_t, CachePair>::const_iterator it;
@ -830,7 +830,7 @@ bool CacheStrapper::findCache(std::string hash, CacheData &data) const
return false; return false;
} }
bool CacheStrapper::CacheExist(CacheData& data){ bool CacheStrapper::CacheExist(RsCacheData& data){
std::string filename = data.path + "/" + data.name; std::string filename = data.path + "/" + data.name;
FILE* file = NULL; FILE* file = NULL;
@ -872,16 +872,16 @@ bool CacheStrapper::saveList(bool &cleanup, std::list<RsItem *>& saveData)
/* iterate through the Caches (local first) */ /* iterate through the Caches (local first) */
std::list<CacheData>::iterator cit; std::list<RsCacheData>::iterator cit;
std::list<CacheData> ownCaches; std::list<RsCacheData> ownCaches;
std::list<CacheData> remoteCaches; std::list<RsCacheData> remoteCaches;
std::string ownId = mLinkMgr->getOwnId(); std::string ownId = mLinkMgr->getOwnId();
std::map<uint16_t, CachePair>::iterator it; std::map<uint16_t, CachePair>::iterator it;
for(it = caches.begin(); it != caches.end(); it++) for(it = caches.begin(); it != caches.end(); it++)
{ {
std::map<CacheId, CacheData>::iterator tit; std::map<CacheId, RsCacheData>::iterator tit;
std::map<CacheId, CacheData> ownTmp; std::map<CacheId, RsCacheData> ownTmp;
(it->second).source -> cachesAvailable(ownId, ownTmp); (it->second).source -> cachesAvailable(ownId, ownTmp);
(it->second).store -> getAllStoredCaches(remoteCaches); (it->second).store -> getAllStoredCaches(remoteCaches);
@ -953,8 +953,8 @@ bool CacheStrapper::loadList(std::list<RsItem *>& load)
std::cerr << "CacheStrapper::loadList() Item Count: " << load.size(); std::cerr << "CacheStrapper::loadList() Item Count: " << load.size();
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
std::list<CacheData> ownCaches; std::list<RsCacheData> ownCaches;
std::list<CacheData> remoteCaches; std::list<RsCacheData> remoteCaches;
std::string ownId = mLinkMgr->getOwnId(); std::string ownId = mLinkMgr->getOwnId();
//peerConnectState ownState; //peerConnectState ownState;
@ -975,7 +975,7 @@ bool CacheStrapper::loadList(std::list<RsItem *>& load)
rscc->print(std::cerr, 10); rscc->print(std::cerr, 10);
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
CacheData cd; RsCacheData cd;
cd.pid = rscc->pid; cd.pid = rscc->pid;
@ -1145,7 +1145,7 @@ bool CacheStrapper::loadList(std::list<RsItem *>& load)
/* request from CacheStore */ /* request from CacheStore */
bool CacheTransfer::RequestCache(CacheData &data, CacheStore *cbStore) bool CacheTransfer::RequestCache(RsCacheData &data, CacheStore *cbStore)
{ {
/* check for a previous request -> and cancel /* check for a previous request -> and cancel
* *
@ -1153,7 +1153,7 @@ bool CacheTransfer::RequestCache(CacheData &data, CacheStore *cbStore)
* - if duplicate hash -> Fail Transfer * - if duplicate hash -> Fail Transfer
*/ */
std::map<std::string, CacheData>::iterator dit; std::map<std::string, RsCacheData>::iterator dit;
std::map<std::string, CacheStore *>::iterator sit; std::map<std::string, CacheStore *>::iterator sit;
for(dit = cbData.begin(); dit != cbData.end(); dit++) for(dit = cbData.begin(); dit != cbData.end(); dit++)
@ -1259,7 +1259,7 @@ bool CacheTransfer::CancelCacheFile(RsPeerId id, std::string path, std::string h
/* internal completion -> does cb */ /* internal completion -> does cb */
bool CacheTransfer::CompletedCache(std::string hash) bool CacheTransfer::CompletedCache(std::string hash)
{ {
std::map<std::string, CacheData>::iterator dit; std::map<std::string, RsCacheData>::iterator dit;
std::map<std::string, CacheStore *>::iterator sit; std::map<std::string, CacheStore *>::iterator sit;
#ifdef CS_DEBUG #ifdef CS_DEBUG
@ -1298,7 +1298,7 @@ bool CacheTransfer::CompletedCache(std::string hash)
/* internal completion -> does cb */ /* internal completion -> does cb */
bool CacheTransfer::FailedCache(std::string hash) bool CacheTransfer::FailedCache(std::string hash)
{ {
std::map<std::string, CacheData>::iterator dit; std::map<std::string, RsCacheData>::iterator dit;
std::map<std::string, CacheStore *>::iterator sit; std::map<std::string, CacheStore *>::iterator sit;
/* find in store.... */ /* find in store.... */
@ -1323,7 +1323,7 @@ bool CacheTransfer::FailedCache(std::string hash)
bool CacheTransfer::FindCacheFile(std::string hash, std::string &path, uint64_t &size) bool CacheTransfer::FindCacheFile(std::string hash, std::string &path, uint64_t &size)
{ {
CacheData data; RsCacheData data;
if (strapper->findCache(hash, data)) if (strapper->findCache(hash, data))
{ {
path = data.path + "/" + data.name; path = data.path + "/" + data.name;

View File

@ -87,7 +87,7 @@ bool operator<(const CacheId &a, const CacheId &b);
* note: this does not actual store the data but serves to locate on network (via hash attribute, * note: this does not actual store the data but serves to locate on network (via hash attribute,
* and on file via path) * and on file via path)
*/ */
class CacheData class RsCacheData
{ {
public: public:
@ -102,7 +102,7 @@ class CacheData
}; };
std::ostream &operator<<(std::ostream &out, const CacheData &d); std::ostream &operator<<(std::ostream &out, const RsCacheData &d);
/***************************** CacheTransfer *****************************/ /***************************** CacheTransfer *****************************/
@ -125,7 +125,7 @@ class CacheTransfer
* At the download side RequestCache() => overloaded RequestCacheFile() * At the download side RequestCache() => overloaded RequestCacheFile()
* the class should then call CompletedCache() or FailedCache() * the class should then call CompletedCache() or FailedCache()
*/ */
bool RequestCache(CacheData &data, CacheStore *cbStore); /* request from CacheStore */ bool RequestCache(RsCacheData &data, CacheStore *cbStore); /* request from CacheStore */
protected: protected:
@ -142,7 +142,7 @@ class CacheTransfer
CacheStrapper *strapper; CacheStrapper *strapper;
std::map<std::string, CacheData> cbData; std::map<std::string, RsCacheData> cbData;
std::map<std::string, CacheStore *> cbStores; std::map<std::string, CacheStore *> cbStores;
}; };
@ -150,7 +150,7 @@ class CacheTransfer
/************************ CacheSource/CacheStore *************************/ /************************ CacheSource/CacheStore *************************/
typedef std::map<uint16_t, CacheData> CacheSet; typedef std::map<uint16_t, RsCacheData> CacheSet;
/*! /*!
* Implements features needed for a service to act as a cachesource and allow pushing a of cache data from service to strapper * Implements features needed for a service to act as a cachesource and allow pushing a of cache data from service to strapper
@ -172,18 +172,18 @@ class CacheSource
* called to determine available cache for peer - * called to determine available cache for peer -
* default acceptable (returns all) * default acceptable (returns all)
*/ */
virtual bool cachesAvailable(RsPeerId pid, std::map<CacheId, CacheData> &ids); virtual bool cachesAvailable(RsPeerId pid, std::map<CacheId, RsCacheData> &ids);
/*! /*!
* function called at startup to load from * function called at startup to load from
* configuration file.... * configuration file....
* to be overloaded by inherited class * to be overloaded by inherited class
*/ */
virtual bool loadLocalCache(const CacheData &data); virtual bool loadLocalCache(const RsCacheData &data);
/* control Caches available */ /* control Caches available */
bool refreshCache(const CacheData &data,const std::set<std::string>& destination_peers); bool refreshCache(const RsCacheData &data,const std::set<std::string>& destination_peers);
bool refreshCache(const CacheData &data); bool refreshCache(const RsCacheData &data);
bool clearCache(CacheId id); bool clearCache(CacheId id);
/* controls if peer is an accepted receiver for cache items. Default is yes. To be overloaded. */ /* controls if peer is an accepted receiver for cache items. Default is yes. To be overloaded. */
@ -198,7 +198,7 @@ class CacheSource
void listCaches(std::ostream &out); void listCaches(std::ostream &out);
/* search */ /* search */
bool findCache(std::string hash, CacheData &data) const; bool findCache(std::string hash, RsCacheData &data) const;
protected: protected:
@ -211,7 +211,7 @@ class CacheSource
void unlockData() const; void unlockData() const;
CacheSet caches; /// all local cache data stored here CacheSet caches; /// all local cache data stored here
std::map<std::string, CacheData> mOldCaches; /// replaced/cleared caches are pushed here (in case requested) std::map<std::string, RsCacheData> mOldCaches; /// replaced/cleared caches are pushed here (in case requested)
private: private:
@ -249,29 +249,29 @@ class CacheStore
* @param data returns cache data for pid/cid set in data itself * @param data returns cache data for pid/cid set in data itself
* @return false is unsuccessful and vice versa * @return false is unsuccessful and vice versa
*/ */
bool getStoredCache(CacheData &data); /* use pid/cid in data */ bool getStoredCache(RsCacheData &data); /* use pid/cid in data */
/*! /*!
* *
* @param data all cache store by cachestore is store here * @param data all cache store by cachestore is store here
* @return false not returned, only true at the moment * @return false not returned, only true at the moment
*/ */
bool getAllStoredCaches(std::list<CacheData> &data); /* use pid/cid in data */ bool getAllStoredCaches(std::list<RsCacheData> &data); /* use pid/cid in data */
/*! /*!
* input from CacheStrapper -> store can then download new data * input from CacheStrapper -> store can then download new data
*/ */
void availableCache(const CacheData &data); void availableCache(const RsCacheData &data);
/*! /*!
* should be called when the download is completed ... cache data is loaded * should be called when the download is completed ... cache data is loaded
*/ */
void downloadedCache(const CacheData &data); void downloadedCache(const RsCacheData &data);
/*! /*!
* called if the download fails, TODO: nothing done yet * called if the download fails, TODO: nothing done yet
*/ */
void failedCache(const CacheData &data); void failedCache(const RsCacheData &data);
/* virtual functions overloaded by cache implementor */ /* virtual functions overloaded by cache implementor */
@ -282,9 +282,9 @@ class CacheStore
* @param data cache data is stored here * @param data cache data is stored here
* @return false is failed (cache does not exist), otherwise true * @return false is failed (cache does not exist), otherwise true
*/ */
virtual bool fetchCache(const CacheData &data); /* a question? */ virtual bool fetchCache(const RsCacheData &data); /* a question? */
virtual int nameCache(CacheData &data); /* fill in the name/path */ virtual int nameCache(RsCacheData &data); /* fill in the name/path */
virtual int loadCache(const CacheData &data); /* actual load, once data available */ virtual int loadCache(const RsCacheData &data); /* actual load, once data available */
/* get private data */ /* get private data */
@ -314,14 +314,14 @@ class CacheStore
* *
* It doesn't lock itself -> to avoid race conditions * It doesn't lock itself -> to avoid race conditions
*/ */
void locked_storeCacheEntry(const CacheData &data); void locked_storeCacheEntry(const RsCacheData &data);
/*! This function is called to store Cache Entry in the CacheStore Table. /*! This function is called to store Cache Entry in the CacheStore Table.
* it must be called from within a Mutex Lock.... * it must be called from within a Mutex Lock....
* *
* It doesn't lock itself -> to avoid race conditions * It doesn't lock itself -> to avoid race conditions
*/ */
bool locked_getStoredCache(CacheData &data); bool locked_getStoredCache(RsCacheData &data);
private: private:
@ -406,20 +406,20 @@ virtual void statusChange(const std::list<pqipeer> &plist);
* @param data * @param data
* *
*/ */
void refreshCache(const CacheData &data); void refreshCache(const RsCacheData &data);
void refreshCache(const CacheData &data,const std::set<std::string>& destination_peers); // specify a particular list of destination peers (self not added!) void refreshCache(const RsCacheData &data,const std::set<std::string>& destination_peers); // specify a particular list of destination peers (self not added!)
/*! /*!
* forces config savelist * forces config savelist
* @param data * @param data
* @see saveList() * @see saveList()
*/ */
void refreshCacheStore(const CacheData &data); void refreshCacheStore(const RsCacheData &data);
/*! /*!
* list of Caches to send out * list of Caches to send out
*/ */
bool getCacheUpdates(std::list<std::pair<RsPeerId, CacheData> > &updates); bool getCacheUpdates(std::list<std::pair<RsPeerId, RsCacheData> > &updates);
/*! /*!
* add to strapper's cachepair set so a related service's store and source can be maintained * add to strapper's cachepair set so a related service's store and source can be maintained
@ -428,15 +428,15 @@ bool getCacheUpdates(std::list<std::pair<RsPeerId, CacheData> > &updates);
void addCachePair(CachePair pair); void addCachePair(CachePair pair);
/*** I/O (2) ***/ /*** I/O (2) ***/
void recvCacheResponse(CacheData &data, time_t ts); void recvCacheResponse(RsCacheData &data, time_t ts);
void handleCacheQuery(RsPeerId id, std::map<CacheId, CacheData> &data); void handleCacheQuery(RsPeerId id, std::map<CacheId, RsCacheData> &data);
/*! /*!
* search through CacheSources. * search through CacheSources.
* @return false if cachedate mapping to hash not found * @return false if cachedate mapping to hash not found
*/ */
bool findCache(std::string hash, CacheData &data) const; bool findCache(std::string hash, RsCacheData &data) const;
/* display */ /* display */
void listCaches(std::ostream &out); void listCaches(std::ostream &out);
@ -453,7 +453,7 @@ void listPeerStatus(std::ostream &out);
* @param data * @param data
* @return whether it exists or not * @return whether it exists or not
*/ */
bool CacheExist(CacheData& data); bool CacheExist(RsCacheData& data);
/* Config */ /* Config */
protected: protected:
@ -472,7 +472,7 @@ virtual bool loadList(std::list<RsItem *>& load);
RsMutex csMtx; /* protect below */ RsMutex csMtx; /* protect below */
std::list<std::pair<RsPeerId, CacheData> > mCacheUpdates; std::list<std::pair<RsPeerId, RsCacheData> > mCacheUpdates;
}; };

View File

@ -433,7 +433,7 @@ bool FileIndexMonitor::convertSharedFilePath(std::string path, std::string &f
} }
bool FileIndexMonitor::loadLocalCache(const CacheData &data) /* called with stored data */ bool FileIndexMonitor::loadLocalCache(const RsCacheData &data) /* called with stored data */
{ {
bool ok = false; bool ok = false;
@ -484,7 +484,7 @@ bool FileIndexMonitor::loadLocalCache(const CacheData &data) /* called with sto
return false; return false;
} }
bool FileIndexMonitor::updateCache(const CacheData &data,const std::set<std::string>& destination_peers) /* we call this one */ bool FileIndexMonitor::updateCache(const RsCacheData &data,const std::set<std::string>& destination_peers) /* we call this one */
{ {
return refreshCache(data,destination_peers); return refreshCache(data,destination_peers);
} }
@ -1124,7 +1124,7 @@ void FileIndexMonitor::locked_saveFileIndexes(bool update_cache)
/* should clean up the previous cache.... */ /* should clean up the previous cache.... */
/* flag as new info */ /* flag as new info */
CacheData data; RsCacheData data;
data.pid = fi.root->id; data.pid = fi.root->id;
data.cid.type = getCacheType(); data.cid.type = getCacheType();
data.cid.subid = n; data.cid.subid = n;
@ -1150,7 +1150,7 @@ void FileIndexMonitor::locked_saveFileIndexes(bool update_cache)
#endif #endif
} }
bool FileIndexMonitor::cachesAvailable(RsPeerId pid,std::map<CacheId, CacheData> &ids) bool FileIndexMonitor::cachesAvailable(RsPeerId pid,std::map<CacheId, RsCacheData> &ids)
{ {
lockData() ; lockData() ;
#ifdef FIM_DEBUG #ifdef FIM_DEBUG
@ -1160,7 +1160,7 @@ bool FileIndexMonitor::cachesAvailable(RsPeerId pid,std::map<CacheId, CacheData>
// Go through the list of saved cache items for that particular peer. // Go through the list of saved cache items for that particular peer.
// //
ids.clear() ; ids.clear() ;
std::map<RsPeerId,CacheData>::const_iterator it(_cache_items_per_peer.find(pid)) ; std::map<RsPeerId,RsCacheData>::const_iterator it(_cache_items_per_peer.find(pid)) ;
std::string ownId = rsPeers->getOwnId() ; std::string ownId = rsPeers->getOwnId() ;
if(it != _cache_items_per_peer.end()) if(it != _cache_items_per_peer.end())

View File

@ -125,8 +125,8 @@ class FileIndexMonitor: public CacheSource, public RsThread
/* Interacting with CacheSource */ /* Interacting with CacheSource */
/* overloaded from CacheSource */ /* overloaded from CacheSource */
virtual bool loadLocalCache(const CacheData &data); /* called with stored data */ virtual bool loadLocalCache(const RsCacheData &data); /* called with stored data */
bool updateCache(const CacheData &data,const std::set<std::string>& dest_peers); /* we call when we have a new cache for others */ bool updateCache(const RsCacheData &data,const std::set<std::string>& dest_peers); /* we call when we have a new cache for others */
/* the FileIndexMonitor inner workings */ /* the FileIndexMonitor inner workings */
@ -152,7 +152,7 @@ class FileIndexMonitor: public CacheSource, public RsThread
/* util fns */ /* util fns */
// from CacheSource // from CacheSource
virtual bool cachesAvailable(RsPeerId /* pid */, std::map<CacheId, CacheData> &ids) ; virtual bool cachesAvailable(RsPeerId /* pid */, std::map<CacheId, RsCacheData> &ids) ;
protected: protected:
// Sets/gets the duration period within which already hashed files are remembered. // Sets/gets the duration period within which already hashed files are remembered.
@ -207,7 +207,7 @@ class FileIndexMonitor: public CacheSource, public RsThread
HashCache hashCache ; HashCache hashCache ;
bool useHashCache ; bool useHashCache ;
std::map<RsPeerId,CacheData> _cache_items_per_peer ; // stored the cache items to be sent to each peer. std::map<RsPeerId,RsCacheData> _cache_items_per_peer ; // stored the cache items to be sent to each peer.
}; };

View File

@ -49,7 +49,7 @@ FileIndexStore::~FileIndexStore()
**/ **/
/* actual load, once data available */ /* actual load, once data available */
int FileIndexStore::loadCache(const CacheData &data) int FileIndexStore::loadCache(const RsCacheData &data)
{ {
#ifdef FIS_DEBUG2 #ifdef FIS_DEBUG2

View File

@ -69,7 +69,7 @@ class FileIndexStore: public CacheStore
virtual ~FileIndexStore(); virtual ~FileIndexStore();
/* virtual functions overloaded by cache implementor */ /* virtual functions overloaded by cache implementor */
virtual int loadCache(const CacheData &data); /* actual load, once data available */ virtual int loadCache(const RsCacheData &data); /* actual load, once data available */
/* Search Interface - For FileTransfer Lookup */ /* Search Interface - For FileTransfer Lookup */
int SearchHash(std::string hash, std::list<FileDetail> &results) const; int SearchHash(std::string hash, std::list<FileDetail> &results) const;

View File

@ -198,7 +198,7 @@ int p3GroupDistrib::tick()
/***************************************************************************************/ /***************************************************************************************/
/***************************************************************************************/ /***************************************************************************************/
int p3GroupDistrib::loadCache(const CacheData &data) int p3GroupDistrib::loadCache(const RsCacheData &data)
{ {
#ifdef DISTRIB_DEBUG #ifdef DISTRIB_DEBUG
std::cerr << "p3GroupDistrib::loadCache()"; std::cerr << "p3GroupDistrib::loadCache()";
@ -226,7 +226,7 @@ int p3GroupDistrib::loadCache(const CacheData &data)
return 1; return 1;
} }
bool p3GroupDistrib::loadLocalCache(const CacheData &data) bool p3GroupDistrib::loadLocalCache(const RsCacheData &data)
{ {
#ifdef DISTRIB_DEBUG #ifdef DISTRIB_DEBUG
std::cerr << "p3GroupDistrib::loadLocalCache()"; std::cerr << "p3GroupDistrib::loadLocalCache()";
@ -255,7 +255,7 @@ bool p3GroupDistrib::loadLocalCache(const CacheData &data)
/* Handle the Cache Pending Setup */ /* Handle the Cache Pending Setup */
CacheDataPending::CacheDataPending(const CacheData &data, bool local, bool historical) CacheDataPending::CacheDataPending(const RsCacheData &data, bool local, bool historical)
:mData(data), mLocal(local), mHistorical(historical) :mData(data), mLocal(local), mHistorical(historical)
{ {
return; return;
@ -290,7 +290,7 @@ void p3GroupDistrib::run() /* called once the thread is started */
#ifdef DISTRIB_DUMMYMSG_DEBUG #ifdef DISTRIB_DUMMYMSG_DEBUG
int printed = 0; int printed = 0;
#endif #endif
CacheData cache; RsCacheData cache;
while(isRunning()) while(isRunning())
{ {
/* */ /* */
@ -354,7 +354,7 @@ void p3GroupDistrib::run() /* called once the thread is started */
int p3GroupDistrib::loadAnyCache(const CacheData &data, bool local, bool historical) int p3GroupDistrib::loadAnyCache(const RsCacheData &data, bool local, bool historical)
{ {
/* if subtype = 1 -> FileGroup, else -> FileMsgs */ /* if subtype = 1 -> FileGroup, else -> FileMsgs */
@ -449,7 +449,7 @@ void p3GroupDistrib::loadFileGroups(const std::string &filename, const std::stri
return; return;
} }
void p3GroupDistrib::loadFileMsgs(const std::string &filename, const CacheData& data, bool local, bool historical) void p3GroupDistrib::loadFileMsgs(const std::string &filename, const RsCacheData& data, bool local, bool historical)
{ {
#ifdef DISTRIB_DEBUG #ifdef DISTRIB_DEBUG
@ -578,7 +578,7 @@ bool p3GroupDistrib::processCacheOptReq(const std::string &grpId)
} }
bool ok; bool ok;
std::list<CacheData> cList; std::list<RsCacheData> cList;
{ {
RsStackMutex stack(distribMtx); RsStackMutex stack(distribMtx);
@ -589,7 +589,7 @@ bool p3GroupDistrib::processCacheOptReq(const std::string &grpId)
if(ok) if(ok)
{ {
std::list<CacheData>::iterator sit = cList.begin(); std::list<RsCacheData>::iterator sit = cList.begin();
for(;sit != cList.end(); sit++) for(;sit != cList.end(); sit++)
loadCacheOptMsgs(*sit, grpId); loadCacheOptMsgs(*sit, grpId);
@ -605,7 +605,7 @@ bool p3GroupDistrib::processCacheOptReq(const std::string &grpId)
return true; return true;
} }
void p3GroupDistrib::loadCacheOptMsgs(const CacheData& data, const std::string& grpId) void p3GroupDistrib::loadCacheOptMsgs(const RsCacheData& data, const std::string& grpId)
{ {
std::string filename = data.path; std::string filename = data.path;
filename += "/"; filename += "/";
@ -1128,7 +1128,7 @@ void p3GroupDistrib::locked_publishPendingMsgs()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
/* get the next message id */ /* get the next message id */
CacheData newCache; RsCacheData newCache;
time_t now = time(NULL); time_t now = time(NULL);
bool ok = true; // hass msg/cache file been written successfully bool ok = true; // hass msg/cache file been written successfully
@ -1230,7 +1230,7 @@ void p3GroupDistrib::publishDistribGroups()
#endif #endif
/* set subid = 1 */ /* set subid = 1 */
CacheData newCache; RsCacheData newCache;
newCache.pid = mOwnId; newCache.pid = mOwnId;
newCache.cid.type = CacheSource::getCacheType(); newCache.cid.type = CacheSource::getCacheType();

View File

@ -207,7 +207,7 @@ const uint32_t GRP_SUBSCRIBED = 0x0005;
const uint32_t GRP_UNSUBSCRIBED = 0x0006; const uint32_t GRP_UNSUBSCRIBED = 0x0006;
typedef std::map<std::string, std::list<CacheData> > CacheOptData; typedef std::map<std::string, std::list<RsCacheData> > CacheOptData;
//! Cache based service to implement group messaging //! Cache based service to implement group messaging
@ -250,8 +250,8 @@ class CacheDataPending
{ {
public: public:
CacheDataPending(const CacheData &data, bool local, bool historical); CacheDataPending(const RsCacheData &data, bool local, bool historical);
CacheData mData; RsCacheData mData;
bool mLocal; bool mLocal;
bool mHistorical; bool mHistorical;
}; };
@ -275,8 +275,8 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu
public: public:
virtual bool loadLocalCache(const CacheData &data); /// overloaded from Cache Source virtual bool loadLocalCache(const RsCacheData &data); /// overloaded from Cache Source
virtual int loadCache(const CacheData &data); /// overloaded from Cache Store virtual int loadCache(const RsCacheData &data); /// overloaded from Cache Store
/* From RsThread */ /* From RsThread */
@ -297,11 +297,11 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu
std::list<CacheDataPending> mPendingCaches; std::list<CacheDataPending> mPendingCaches;
/* top level load */ /* top level load */
int loadAnyCache(const CacheData &data, bool local, bool historical); int loadAnyCache(const RsCacheData &data, bool local, bool historical);
/* load cache files */ /* load cache files */
void loadFileGroups(const std::string &filename, const std::string &src, bool local, bool historical); void loadFileGroups(const std::string &filename, const std::string &src, bool local, bool historical);
void loadFileMsgs(const std::string &filename, const CacheData& , bool local, bool historical); void loadFileMsgs(const std::string &filename, const RsCacheData& , bool local, bool historical);
bool backUpKeys(const std::list<RsDistribGrpKey* > &keysToBackUp, std::string grpId); bool backUpKeys(const std::list<RsDistribGrpKey* > &keysToBackUp, std::string grpId);
void locked_sharePubKey(); void locked_sharePubKey();
@ -318,7 +318,7 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu
* Simply load cache opt messages * Simply load cache opt messages
* @param data * @param data
*/ */
void loadCacheOptMsgs(const CacheData& data, const std::string& grpId); void loadCacheOptMsgs(const RsCacheData& data, const std::string& grpId);
protected: protected:

View File

@ -396,7 +396,7 @@ bool ftCacheStrapper::search(const std::string &hash, FileSearchFlags hintflags,
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
CacheData data; RsCacheData data;
if (findCache(hash, data)) if (findCache(hash, data))
{ {
#ifdef DB_DEBUG #ifdef DB_DEBUG

View File

@ -1329,7 +1329,7 @@ bool ftServer::handleCacheData()
#endif #endif
/* these go to the CacheStrapper! */ /* these go to the CacheStrapper! */
CacheData data; RsCacheData data;
data.pid = ci->PeerId(); data.pid = ci->PeerId();
data.cid = CacheId(ci->cacheType, ci->cacheSubId); data.cid = CacheId(ci->cacheType, ci->cacheSubId);
data.path = ci->file.path; data.path = ci->file.path;
@ -1359,8 +1359,8 @@ bool ftServer::handleCacheData()
// Now handle it replacement (pushed cache results) // Now handle it replacement (pushed cache results)
{ {
std::list<std::pair<RsPeerId, CacheData> > cacheUpdates; std::list<std::pair<RsPeerId, RsCacheData> > cacheUpdates;
std::list<std::pair<RsPeerId, CacheData> >::iterator it; std::list<std::pair<RsPeerId, RsCacheData> >::iterator it;
mCacheStrapper->getCacheUpdates(cacheUpdates); mCacheStrapper->getCacheUpdates(cacheUpdates);
for(it = cacheUpdates.begin(); it != cacheUpdates.end(); it++) for(it = cacheUpdates.begin(); it != cacheUpdates.end(); it++)

View File

@ -93,7 +93,7 @@ int main(int argc, char **argv)
sc3.addCachePair(cp3); sc3.addCachePair(cp3);
/* add in a cache to sc2 */ /* add in a cache to sc2 */
CacheData cdata; RsCacheData cdata;
cdata.pid = pid1; cdata.pid = pid1;
cdata.cid = cid1; cdata.cid = cid1;
@ -191,8 +191,8 @@ void handleQuery(CacheStrapper *csp, RsPeerId pid,
std::map<RsPeerId, CacheStrapper *>::iterator sit; std::map<RsPeerId, CacheStrapper *>::iterator sit;
if (strappers.end() != (sit = strappers.find(*pit))) if (strappers.end() != (sit = strappers.find(*pit)))
{ {
std::map<CacheId, CacheData> hashs; std::map<CacheId, RsCacheData> hashs;
std::map<CacheId, CacheData>::iterator hit; std::map<CacheId, RsCacheData>::iterator hit;
(sit -> second) -> handleCacheQuery(pid, hashs); (sit -> second) -> handleCacheQuery(pid, hashs);
for(hit = hashs.begin(); hit != hashs.end(); hit++) for(hit = hashs.begin(); hit != hashs.end(); hit++)
{ {

View File

@ -66,7 +66,7 @@ p3Ranking::p3Ranking(RsPluginHandler* pgHandler)
mSortType = RS_RANK_ALG; mSortType = RS_RANK_ALG;
} }
bool p3Ranking::loadLocalCache(const CacheData &data) bool p3Ranking::loadLocalCache(const RsCacheData &data)
{ {
std::string filename = data.path + '/' + data.name; std::string filename = data.path + '/' + data.name;
std::string hash = data.hash; std::string hash = data.hash;
@ -100,7 +100,7 @@ bool p3Ranking::loadLocalCache(const CacheData &data)
return true; return true;
} }
int p3Ranking::loadCache(const CacheData &data) int p3Ranking::loadCache(const RsCacheData &data)
{ {
std::string filename = data.path + '/' + data.name; std::string filename = data.path + '/' + data.name;
std::string hash = data.hash; std::string hash = data.hash;
@ -356,7 +356,7 @@ void p3Ranking::publishMsgs(bool own)
} /********** STACK LOCKED MTX ******/ } /********** STACK LOCKED MTX ******/
/* flag as new info */ /* flag as new info */
CacheData data; RsCacheData data;
{ RsStackMutex stack(mRankMtx); /********** STACK LOCKED MTX ******/ { RsStackMutex stack(mRankMtx); /********** STACK LOCKED MTX ******/
data.pid = mOwnId; data.pid = mOwnId;

View File

@ -71,10 +71,10 @@ class p3Ranking: public RsCacheService, public RsRanks
/******************************* CACHE SOURCE / STORE Interface *********************/ /******************************* CACHE SOURCE / STORE Interface *********************/
/* overloaded functions from Cache Source */ /* overloaded functions from Cache Source */
virtual bool loadLocalCache(const CacheData &data); virtual bool loadLocalCache(const RsCacheData &data);
/* overloaded functions from Cache Store */ /* overloaded functions from Cache Store */
virtual int loadCache(const CacheData &data); virtual int loadCache(const RsCacheData &data);
/******************************* CACHE SOURCE / STORE Interface *********************/ /******************************* CACHE SOURCE / STORE Interface *********************/