llcachename.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLCACHENAME_H
00033 #define LL_LLCACHENAME_H
00034 
00035 class LLMessageSystem;
00036 class LLHost;
00037 class LLUUID;
00038 
00039 // agent_id/group_id, first_name, last_name, is_group, user_data
00040 typedef void (*LLCacheNameCallback)(const LLUUID&, const char*, const char*, BOOL, void*);
00041 
00042 // Here's the theory:
00043 // If you request a name that isn't in the cache, it returns "waiting"
00044 // and requests the data.  After the data arrives, you get that on 
00045 // subsequent calls.
00046 // If the data hasn't been updated in an hour, it requests it again,
00047 // but keeps giving you the old value until new data arrives.
00048 // If you haven't requested the data in an hour, it releases it.
00049 class LLCacheName
00050 {
00051 public:
00052         LLCacheName(LLMessageSystem* msg);
00053         LLCacheName(LLMessageSystem* msg, const LLHost& upstream_host);
00054         ~LLCacheName();
00055 
00056         // registers the upstream host
00057         // for viewers, this is the currently connected simulator
00058         // for simulators, this is the data server
00059         void setUpstream(const LLHost& upstream_host);
00060 
00061         void addObserver(LLCacheNameCallback callback);
00062         void removeObserver(LLCacheNameCallback callback);
00063 
00064         void cancelCallback(const LLUUID& id, LLCacheNameCallback callback, void* user_data = NULL);
00065 
00066         // storing cache on disk; for viewer, in name.cache
00067         void importFile(FILE* fp);
00068         void exportFile(FILE* fp);
00069 
00070         // If available, copies the first and last name into the strings provided.
00071         // first must be at least DB_FIRST_NAME_BUF_SIZE characters.
00072         // last must be at least DB_LAST_NAME_BUF_SIZE characters.
00073         // If not available, copies the string "waiting".
00074         // Returns TRUE iff available.
00075         BOOL getName(const LLUUID& id, char* first, char* last);
00076         
00077         // If available, this method copies the group name into the string
00078         // provided. The caller must allocate at least
00079         // DB_GROUP_NAME_BUF_SIZE characters. If not available, this
00080         // method copies the string "waiting". Returns TRUE iff available.
00081         BOOL getGroupName(const LLUUID& id, char* group);
00082 
00083         // Call the callback with the group or avatar name.
00084         // If the data is currently available, may call the callback immediatly
00085         // otherwise, will request the data, and will call the callback when
00086         // available.  There is no garuntee the callback will ever be called.
00087         void get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callback, void* user_data = NULL);
00088         
00089         // LEGACY
00090         void getName(const LLUUID& id, LLCacheNameCallback callback, void* user_data = NULL)
00091                         { get(id, FALSE, callback, user_data); }
00092 
00093         // This method needs to be called from time to time to send out
00094         // requests.
00095         void processPending();
00096 
00097         // Expire entries created more than "secs" seconds ago.
00098         void deleteEntriesOlderThan(S32 secs);
00099 
00100         // Debugging
00101         void dump();            // Dumps the contents of the cache
00102         void dumpStats();       // Dumps the sizes of the cache and associated queues.
00103 
00104         static LLString getDefaultName();
00105 
00106 private:
00107         class Impl;
00108         Impl& impl;
00109 };
00110 
00111 
00112 
00113 extern LLCacheName* gCacheName;
00114 
00115 #endif

Generated on Thu Jul 1 06:08:20 2010 for Second Life Viewer by  doxygen 1.4.7