summaryrefslogtreecommitdiff
path: root/indra/llmessage/llexperiencecache.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmessage/llexperiencecache.h')
-rw-r--r--indra/llmessage/llexperiencecache.h67
1 files changed, 47 insertions, 20 deletions
diff --git a/indra/llmessage/llexperiencecache.h b/indra/llmessage/llexperiencecache.h
index e669ee888e..8a55719443 100644
--- a/indra/llmessage/llexperiencecache.h
+++ b/indra/llmessage/llexperiencecache.h
@@ -30,15 +30,47 @@
#define LL_LLEXPERIENCECACHE_H
#include "linden_common.h"
+#include "llsingleton.h"
+#include "llsd.h"
#include <boost/signals2.hpp>
+#include <boost/function.hpp>
class LLSD;
class LLUUID;
-
-namespace LLExperienceCache
+class LLExperienceCache: public LLSingleton < LLExperienceCache >
{
+ friend class LLSingleton < LLExperienceCache > ;
+
+public:
+ typedef boost::function<void(const LLSD &)> Callback_t;
+
+ void erase(const LLUUID& key);
+ bool fetch(const LLUUID& key, bool refresh = false);
+ void insert(const LLSD& experience_data);
+ const LLSD& get(const LLUUID& key);
+
+ // If name information is in cache, callback will be called immediately.
+ void get(const LLUUID& key, Callback_t slot);
+
+private:
+ // Callback types for get()
+// typedef boost::signals2::signal < void(const LLSD &) > callback_signal_t;
+ typedef boost::signals2::signal < Callback_t > callback_signal_t;
+ typedef std::map<LLUUID, LLSD> cache_t;
+
+//--------------------------------------------
+ LLExperienceCache();
+ virtual ~LLExperienceCache();
+
+ void exportFile(std::ostream& ostr) const;
+ void importFile(std::istream& istr);
+
+//--------------------------------------------
+ void processExperience(const LLUUID& public_key, const LLSD& experience);
+
+
const std::string PRIVATE_KEY = "private_id";
const std::string MISSING = "DoesNotExist";
@@ -61,19 +93,12 @@ namespace LLExperienceCache
const int PROPERTY_GRID = 1 << 4;
const int PROPERTY_PRIVATE = 1 << 5;
const int PROPERTY_DISABLED = 1 << 6;
- const int PROPERTY_SUSPENDED = 1 << 7;
-
+ const int PROPERTY_SUSPENDED = 1 << 7;
// default values
const static F64 DEFAULT_EXPIRATION = 600.0;
const static S32 DEFAULT_QUOTA = 128; // this is megabytes
- // Callback types for get() below
- typedef boost::signals2::signal<void (const LLSD& experience)>
- callback_signal_t;
- typedef callback_signal_t::slot_type callback_slot_t;
- typedef std::map<LLUUID, LLSD> cache_t;
-
void setLookupURL(const std::string& lookup_url);
bool hasLookupURL();
@@ -81,24 +106,26 @@ namespace LLExperienceCache
void setMaximumLookups(int maximumLookups);
void idle();
- void exportFile(std::ostream& ostr);
- void importFile(std::istream& istr);
- void initClass();
void bootstrap(const LLSD& legacyKeys, int initialExpiration);
- void erase(const LLUUID& key);
- bool fetch(const LLUUID& key, bool refresh=false);
- void insert(const LLSD& experience_data);
- const LLSD& get(const LLUUID& key);
-
- // If name information is in cache, callback will be called immediately.
- void get(const LLUUID& key, callback_slot_t slot);
const cache_t& getCached();
// maps an experience private key to the experience id
LLUUID getExperienceId(const LLUUID& private_key, bool null_if_not_found=false);
+ //=====================================================================
+ inline friend std::ostream &operator << (std::ostream &os, const LLExperienceCache &cache)
+ {
+ cache.exportFile(os);
+ return os;
+ }
+
+ inline friend std::istream &operator >> (std::istream &is, LLExperienceCache &cache)
+ {
+ cache.importFile(is);
+ return is;
+ }
};
#endif // LL_LLEXPERIENCECACHE_H