llviewercommunication.h

Go to the documentation of this file.
00001 
00030 #ifndef LL_LLVIEWERCOMMUNICATION_H
00031 #define LL_LLVIEWERCOMMUNICATION_H
00032 
00033 #include <map>
00034 
00043 class LLViewerCircuit
00044 {
00045 public:
00046         LLViewerCircuit(U32 channel) : mChannel(channel) {};
00047         LLViewerCircuit() : mChannel(0) {}
00048 
00052         U32 getChannel() const { return mChannel; }
00053 
00058         void sendReply(const LLString& data);
00059 protected:
00060         U32 mChannel;
00061 };
00062 
00063 
00064 
00065 typedef void(*viewer_extension_callback_t)(LLString& data, LLViewerCircuit& circuit, void *user_data);
00066 
00067 
00072 class LLViewerExtension
00073 {
00074 public:
00084         LLViewerExtension(const LLString& name = "<unknown>", const U32 version = 0, viewer_extension_callback_t callback = NULL, void *user_data = NULL, const LLString& author = "", const LLString& description = "") :
00085                 mName(name), mAuthor(author), mDescription(description), mVersion(version), mCallback(callback), mUserData(user_data) {};
00086 
00087         LLString asString() const { return mName; }
00088 
00089         LLString getName() const { return mName; }
00090         LLString getAuthor() const { return mAuthor; }
00091         LLString getDescription() const { return mDescription; }
00092         U32 getVersion() const { return mVersion; }
00093 
00099         void notify(LLString& data, LLViewerCircuit& circuit) { mCallback(data, circuit, mUserData); }
00100 protected:
00101         LLString mName;
00102         LLString mAuthor;
00103         LLString mDescription;
00104         U32 mVersion;
00105 
00106         viewer_extension_callback_t mCallback;
00107         void *mUserData;
00108 };
00109 
00110 
00111 
00117 class LLViewerCommunication
00118 {
00119 public:
00120         LLViewerCommunication();
00121 
00128         bool parse(const LLString &text, const LLUUID& speaker);
00129         bool parse(char *text, const LLUUID& speaker) { LLString tmp = text; return parse(tmp, speaker); }
00130 
00131         void registerExtension(LLViewerExtension ext) { mExtensions[ext.getName()] = ext; }
00132         
00133 
00134 protected:
00135         std::map<LLString, LLViewerExtension> mExtensions;
00136         std::map<LLUUID, LLViewerCircuit> mCircuits;
00137 };
00138 
00139 extern LLViewerCommunication *gViewerCommunication;
00140 
00141 #endif

Generated on Thu Jul 1 06:09:27 2010 for Second Life Viewer by  doxygen 1.4.7