/home/tetron/hack/vos/libs/vos/metaobjects/a3dl/actor.hh
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _ACTOR_HH_
00025 #define _ACTOR_HH_
00026
00027 #include <vos/vos/vos.hh>
00028
00029 #include "a3dldefs.hh"
00030
00031 #ifndef A3DL_EXPORTS
00032 IMPORT_METAOBJECT_FACTORIES(A3DL_Actor)
00033 #endif
00034
00035 namespace A3DL
00036 {
00037 class Actor;
00038 class ActionEvent;
00039
00040 class A3DL_API ActionListener
00041 {
00042 public:
00043 virtual ~ActionListener() { }
00044 virtual void notifyActionChange(const ActionEvent& ae) = 0;
00045 };
00046
00047 class A3DL_API ActionEvent : public VUtil::RefCounted
00048 {
00049 public:
00050 typedef enum { SetActionCycle, StartActionCycle, StopAction,
00051 StopAllActions, DoActionOnce } EventType;
00052 private:
00053 EventType type;
00054 VUtil::vRef<Actor> actor;
00055 std::string action;
00056 float weight;
00057 float delayIn;
00058 float delayOut;
00059 public:
00060 ActionEvent(EventType et, Actor* actor,
00061 const std::string& action = "",
00062 float weight = 0.0,
00063 float delayIn = 0.0,
00064 float delayOut = 0.0);
00065 ~ActionEvent();
00066
00067 EventType getEventType() const { return type; };
00068 const std::string& getAction() const { return action; };
00069 VUtil::vRef<Actor> getActor() const;
00070 float getWeight() const { return weight; }
00071 float getDelayIn() const { return delayIn; }
00072 float getDelayOut() const { return delayOut; }
00073
00074 void deliverTo(ActionListener* al) { al->notifyActionChange(*this); }
00075 };
00076
00077 class A3DL_API RemoteActionListener : public VOS::MetaObject, public ActionListener
00078 {
00079 public:
00080 RemoteActionListener(VOS::VobjectBase* superobject);
00081 virtual ~RemoteActionListener();
00082
00083 virtual void notifyActionChange(const ActionEvent& ae);
00084 };
00085
00086 class A3DL_API Actor : public VOS::MetaObject
00087 {
00088 protected:
00089 VUtil::ListenerBase<ActionListener, ActionEvent> actionListeners;
00090
00091 std::map< std::string, VUtil::vRef<ActionEvent> > actions;
00092
00093 public:
00094 Actor(VOS::VobjectBase* superobject);
00095 virtual ~Actor();
00096
00097 virtual const std::string getVOSType();
00098
00099 virtual void addActionListener(ActionListener* al);
00100 virtual void removeActionListener(ActionListener* al);
00101
00102 virtual void setActionCycle(const std::string& action, float weight) = 0;
00103 virtual void startActionCycle(const std::string& action, float weight,
00104 float delay) = 0;
00105 virtual void stopAction(const std::string& action, float delay) = 0;
00106 virtual void stopAllActions() = 0;
00107 virtual void doActionOnce(const std::string& action, float delayIn,
00108 float delayOut) = 0;
00109 virtual bool isDoingAction(const std::string& action)
00110 { return actions.count(action) > 0; }
00111 };
00112
00113 class A3DL_API LocalActor : public virtual Actor
00114 {
00115 public:
00116 LocalActor(VOS::VobjectBase* superobject);
00117 virtual ~LocalActor();
00118
00119 static VOS::MetaObject* new_LocalActor(VOS::VobjectBase* superobject,
00120 const std::string& type);
00121
00122 virtual void addActionListener(ActionListener* al);
00123 virtual void removeActionListener(ActionListener* al);
00124
00125 virtual void setActionCycle(const std::string& action, float weight);
00126 virtual void startActionCycle(const std::string& action, float weight, float delay);
00127 virtual void stopAction(const std::string& action, float delay);
00128 virtual void stopAllActions();
00129 virtual void doActionOnce(const std::string& action, float delayIn, float delayOut);
00130
00131 virtual void startListeningHandler(VOS::Message* m);
00132 virtual void stopListeningHandler(VOS::Message* m);
00133 virtual void actionChangeHandler(VOS::Message* m);
00134 };
00135
00136 class A3DL_API RemoteActor : public virtual Actor
00137 {
00138 public:
00139 RemoteActor(VOS::VobjectBase* superobject);
00140 virtual ~RemoteActor();
00141
00142 static VOS::MetaObject* new_RemoteActor(VOS::VobjectBase* superobject, const std::string& type);
00143
00144 virtual void addActionListener(ActionListener* al);
00145 virtual void removeActionListener(ActionListener* al);
00146
00147 virtual void setActionCycle(const std::string& action, float weight);
00148 virtual void startActionCycle(const std::string& action, float weight, float delay);
00149 virtual void stopAction(const std::string& action, float delay);
00150 virtual void stopAllActions();
00151 virtual void doActionOnce(const std::string& action, float delayIn, float delayOut);
00152
00153 virtual void startListeningUpdateHandler(VOS::Message* m);
00154 virtual void stopListeningUpdateHandler(VOS::Message* m);
00155 virtual void actionChangeUpdateHandler(VOS::Message* m);
00156 };
00157 };
00158
00159 #endif