llgesture.h

Go to the documentation of this file.
00001 
00033 #ifndef LL_LLGESTURE_H
00034 #define LL_LLGESTURE_H
00035 
00036 #include "llanimationstates.h"
00037 #include "lluuid.h"
00038 #include "llstring.h"
00039 #include "lldarray.h"
00040 
00041 class LLGesture
00042 {
00043 public:
00044         LLGesture();
00045         LLGesture(KEY key, MASK mask, const std::string &trigger, 
00046                 const LLUUID &sound_item_id, const std::string &animation, 
00047                 const std::string &output_string);
00048 
00049         LLGesture(U8 **buffer, S32 max_size); // deserializes, advances buffer
00050         LLGesture(const LLGesture &gesture);
00051         const LLGesture &operator=(const LLGesture &rhs);
00052 
00053         virtual ~LLGesture() {};
00054 
00055         // Accessors
00056         KEY                                     getKey() const                  { return mKey; }
00057         MASK                            getMask() const                 { return mMask; }
00058         const std::string&      getTrigger() const              { return mTrigger; }
00059         const LLUUID&           getSound() const                { return mSoundItemID; }
00060         const std::string&      getAnimation() const    { return mAnimation; }
00061         const std::string&      getOutputString() const { return mOutputString; }
00062 
00063         // Triggers if a key/mask matches it
00064         virtual BOOL trigger(KEY key, MASK mask);
00065 
00066         // Triggers if case-insensitive substring matches (assumes string is lowercase)
00067         virtual BOOL trigger(const LLString &string);
00068 
00069         // non-endian-neutral serialization
00070         U8 *serialize(U8 *buffer) const;
00071         U8 *deserialize(U8 *buffer, S32 max_size);
00072         static S32 getMaxSerialSize();
00073 
00074 protected:
00075         KEY                                     mKey;                   // usually a function key
00076         MASK                            mMask;                  // usually MASK_NONE, or MASK_SHIFT
00077         std::string             mTrigger;               // string, no whitespace allowed
00078         std::string             mTriggerLower;  // lowercase version of mTrigger
00079         LLUUID                          mSoundItemID;   // ItemID of sound to play, LLUUID::null if none
00080         std::string                     mAnimation;             // canonical name of animation or face animation
00081         std::string             mOutputString;  // string to say
00082 
00083         static const S32        MAX_SERIAL_SIZE;
00084 };
00085 
00086 class LLGestureList
00087 {
00088 public:
00089         LLGestureList();
00090         virtual ~LLGestureList();
00091 
00092         // Triggers if a key/mask matches one in the list
00093         BOOL trigger(KEY key, MASK mask);
00094 
00095         // Triggers if substring matches and generates revised string.
00096         BOOL triggerAndReviseString(const LLString &string, LLString* revised_string);
00097 
00098         // Used for construction from UI
00099         S32 count() const                                               { return mList.count(); }
00100         virtual LLGesture* get(S32 i) const             { return mList.get(i); }
00101         virtual void put(LLGesture* gesture)    { mList.put( gesture ); }
00102         void deleteAll();
00103 
00104         // non-endian-neutral serialization
00105         U8 *serialize(U8 *buffer) const;
00106         U8 *deserialize(U8 *buffer, S32 max_size);
00107         S32 getMaxSerialSize();
00108 
00109 protected:
00110         // overridden by child class to use local LLGesture implementation
00111         virtual LLGesture *create_gesture(U8 **buffer, S32 max_size);
00112 
00113 protected:
00114         LLDynamicArray<LLGesture*>      mList;
00115 
00116         static const S32        SERIAL_HEADER_SIZE;
00117 };
00118 
00119 #endif

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