1 // This file may be redistributed and modified only under the terms of
2 // the GNU Lesser General Public License (See COPYING for details).
3 // Copyright 2000-2001 Stefanus Du Toit and Aloril.
4 // Copyright 2001-2005 Alistair Riddoch.
5 // Automatically generated using gen_cpp.py.
6 
7 #ifndef ATLAS_OBJECTS_DISPATCHER_H
8 #define ATLAS_OBJECTS_DISPATCHER_H
9 
10 
11 #include <Atlas/Objects/Decoder.h>
12 
13 #include <Atlas/Objects/Root.h>
14 #include <Atlas/Objects/Entity.h>
15 #include <Atlas/Objects/Operation.h>
16 
17 namespace Atlas { namespace Objects {
18 
19 /** Objects hierarchy dispatcher
20  *
21  * This dispatcher can be bound to a codec, will assemble incoming messages,
22  * check their type, convert them into the appropriate instance in the
23  * Objects hierarchy and call the relevant member functions, which
24  * subclasses can conveniently override to pick up the object.
25  *
26  * @see Atlas::Objects::Encoder
27  * @author Stefanus Du Toit <sdt@gmx.net>
28  */
29 class Dispatcher : public Atlas::Objects::ObjectsDecoder
30 {
31     typedef void (Dispatcher::*objectArrivedPtr)(const Root&);
32     typedef std::map<int, objectArrivedPtr> methodMap_t;
33 public:
34     /// Default destructor.
35     virtual ~Dispatcher();
36 
37     /// Add a new method for Objects class defined by application
38     void addMethod(int, objectArrivedPtr method);
39 protected:
40     /// Store extension methods for Objects classes defined by application
41     methodMap_t m_methods;
42 
43     /// An unknown object has arrived.
unknownObjectArrived(const Root &)44     virtual void unknownObjectArrived(const Root&) { }
45 
46     /// An object has arrived for dispatch.
47     virtual void objectArrived(const Root&);
48 
49     /// call right object*Arrived method
50     virtual void dispatchObject(const Root& obj);
51 
52     /// Override this to get called when a Root object arrives.
objectRootArrived(const Root &)53     virtual void objectRootArrived(const Root&) { }
54     /// Override this to get called when a RootEntity object arrives.
objectRootEntityArrived(const Entity::RootEntity &)55     virtual void objectRootEntityArrived(const Entity::RootEntity&) { }
56     /// Override this to get called when a AdminEntity object arrives.
objectAdminEntityArrived(const Entity::AdminEntity &)57     virtual void objectAdminEntityArrived(const Entity::AdminEntity&) { }
58     /// Override this to get called when a Account object arrives.
objectAccountArrived(const Entity::Account &)59     virtual void objectAccountArrived(const Entity::Account&) { }
60     /// Override this to get called when a Player object arrives.
objectPlayerArrived(const Entity::Player &)61     virtual void objectPlayerArrived(const Entity::Player&) { }
62     /// Override this to get called when a Admin object arrives.
objectAdminArrived(const Entity::Admin &)63     virtual void objectAdminArrived(const Entity::Admin&) { }
64     /// Override this to get called when a Game object arrives.
objectGameArrived(const Entity::Game &)65     virtual void objectGameArrived(const Entity::Game&) { }
66     /// Override this to get called when a GameEntity object arrives.
objectGameEntityArrived(const Entity::GameEntity &)67     virtual void objectGameEntityArrived(const Entity::GameEntity&) { }
68     /// Override this to get called when a RootOperation object arrives.
objectRootOperationArrived(const Operation::RootOperation &)69     virtual void objectRootOperationArrived(const Operation::RootOperation&) { }
70     /// Override this to get called when a Action object arrives.
objectActionArrived(const Operation::Action &)71     virtual void objectActionArrived(const Operation::Action&) { }
72     /// Override this to get called when a Create object arrives.
objectCreateArrived(const Operation::Create &)73     virtual void objectCreateArrived(const Operation::Create&) { }
74     /// Override this to get called when a Combine object arrives.
objectCombineArrived(const Operation::Combine &)75     virtual void objectCombineArrived(const Operation::Combine&) { }
76     /// Override this to get called when a Divide object arrives.
objectDivideArrived(const Operation::Divide &)77     virtual void objectDivideArrived(const Operation::Divide&) { }
78     /// Override this to get called when a Communicate object arrives.
objectCommunicateArrived(const Operation::Communicate &)79     virtual void objectCommunicateArrived(const Operation::Communicate&) { }
80     /// Override this to get called when a Talk object arrives.
objectTalkArrived(const Operation::Talk &)81     virtual void objectTalkArrived(const Operation::Talk&) { }
82     /// Override this to get called when a Delete object arrives.
objectDeleteArrived(const Operation::Delete &)83     virtual void objectDeleteArrived(const Operation::Delete&) { }
84     /// Override this to get called when a Set object arrives.
objectSetArrived(const Operation::Set &)85     virtual void objectSetArrived(const Operation::Set&) { }
86     /// Override this to get called when a Affect object arrives.
objectAffectArrived(const Operation::Affect &)87     virtual void objectAffectArrived(const Operation::Affect&) { }
88     /// Override this to get called when a Move object arrives.
objectMoveArrived(const Operation::Move &)89     virtual void objectMoveArrived(const Operation::Move&) { }
90     /// Override this to get called when a Wield object arrives.
objectWieldArrived(const Operation::Wield &)91     virtual void objectWieldArrived(const Operation::Wield&) { }
92     /// Override this to get called when a Get object arrives.
objectGetArrived(const Operation::Get &)93     virtual void objectGetArrived(const Operation::Get&) { }
94     /// Override this to get called when a Perceive object arrives.
objectPerceiveArrived(const Operation::Perceive &)95     virtual void objectPerceiveArrived(const Operation::Perceive&) { }
96     /// Override this to get called when a Look object arrives.
objectLookArrived(const Operation::Look &)97     virtual void objectLookArrived(const Operation::Look&) { }
98     /// Override this to get called when a Listen object arrives.
objectListenArrived(const Operation::Listen &)99     virtual void objectListenArrived(const Operation::Listen&) { }
100     /// Override this to get called when a Sniff object arrives.
objectSniffArrived(const Operation::Sniff &)101     virtual void objectSniffArrived(const Operation::Sniff&) { }
102     /// Override this to get called when a Touch object arrives.
objectTouchArrived(const Operation::Touch &)103     virtual void objectTouchArrived(const Operation::Touch&) { }
104     /// Override this to get called when a Login object arrives.
objectLoginArrived(const Operation::Login &)105     virtual void objectLoginArrived(const Operation::Login&) { }
106     /// Override this to get called when a Logout object arrives.
objectLogoutArrived(const Operation::Logout &)107     virtual void objectLogoutArrived(const Operation::Logout&) { }
108     /// Override this to get called when a Imaginary object arrives.
objectImaginaryArrived(const Operation::Imaginary &)109     virtual void objectImaginaryArrived(const Operation::Imaginary&) { }
110     /// Override this to get called when a Use object arrives.
objectUseArrived(const Operation::Use &)111     virtual void objectUseArrived(const Operation::Use&) { }
112     /// Override this to get called when a Info object arrives.
objectInfoArrived(const Operation::Info &)113     virtual void objectInfoArrived(const Operation::Info&) { }
114     /// Override this to get called when a Perception object arrives.
objectPerceptionArrived(const Operation::Perception &)115     virtual void objectPerceptionArrived(const Operation::Perception&) { }
116     /// Override this to get called when a Sight object arrives.
objectSightArrived(const Operation::Sight &)117     virtual void objectSightArrived(const Operation::Sight&) { }
118     /// Override this to get called when a Appearance object arrives.
objectAppearanceArrived(const Operation::Appearance &)119     virtual void objectAppearanceArrived(const Operation::Appearance&) { }
120     /// Override this to get called when a Disappearance object arrives.
objectDisappearanceArrived(const Operation::Disappearance &)121     virtual void objectDisappearanceArrived(const Operation::Disappearance&) { }
122     /// Override this to get called when a Sound object arrives.
objectSoundArrived(const Operation::Sound &)123     virtual void objectSoundArrived(const Operation::Sound&) { }
124     /// Override this to get called when a Smell object arrives.
objectSmellArrived(const Operation::Smell &)125     virtual void objectSmellArrived(const Operation::Smell&) { }
126     /// Override this to get called when a Feel object arrives.
objectFeelArrived(const Operation::Feel &)127     virtual void objectFeelArrived(const Operation::Feel&) { }
128     /// Override this to get called when a Error object arrives.
objectErrorArrived(const Operation::Error &)129     virtual void objectErrorArrived(const Operation::Error&) { }
130     /// Override this to get called when a Anonymous object arrives.
objectAnonymousArrived(const Entity::Anonymous &)131     virtual void objectAnonymousArrived(const Entity::Anonymous&) { }
132     /// Override this to get called when a Generic object arrives.
objectGenericArrived(const Operation::Generic &)133     virtual void objectGenericArrived(const Operation::Generic&) { }
134 };
135 
136 } } // namespace Atlas::Objects
137 
138 #endif // ATLAS_OBJECTS_DISPATCHER_H
139