interreality.org [VOS]
[Home] [About]
[Screenshots]
[Download]
[News]
[Community]
[Documentation] [Manual]
[Bugs & Requests] [Wiki]

/home/tetron/hack/vos/libs/vos/vos/siteextension.hh

Go to the documentation of this file.
00001 #ifndef _SITEEXTENSION_HH_
00002 #define _SITEEXTENSION_HH_
00003 
00004 #include <vos/vos/vobjectbase.hh>
00005 #include <vos/vos/identity.hh>
00006 
00007 namespace VOS {
00008     /** @class SiteExtension siteextension.hh vos/vos/siteextension.hh
00009         @ingroup libvos
00010 
00011         Allows you to hook into various methods on a Site object to
00012         extend their functionality.  You want to subclass this and
00013         override the methods you are interested in.  The pre_ methods
00014         are called prior to running the default behavior of the
00015         method.  The post_ methods are run after the default behavior
00016         of the method has executed.  If you return "false" from a pre_
00017         method this will prevent the default behavior from being run,
00018         meaning it will return after running all the pre_ extensions;
00019         this also means it will also skip running any post_ methods.
00020 
00021         You can also override doSendMessage(), generally this is done
00022         to implement the actual physical sending the serialized
00023         version of a message to a remote site.
00024     */
00025     class VOS_API SiteExtension : public Dispatchable
00026     {
00027     public:
00028         virtual ~SiteExtension() { }
00029 
00030         virtual void siteExtensionAttachedTo(Site* st) { };
00031 
00032         virtual VUtil::vRef<VobjectBase> pre_createVobject(VobjectState& state, Vobject* requester, const char* name,
00033                                                     const std::deque<std::string>& typelist)
00034             {
00035                 return VUtil::vRef<VobjectBase>();
00036             };
00037         virtual void post_createVobject(VobjectState& state, Vobject* requester, VobjectBase* newvobject) { };
00038 
00039         virtual bool pre_renameVobject(VobjectState& state, Vobject* requester,
00040                                        const std::string& oldname, const std::string& newname) { return true; };
00041         virtual void post_renameVobject(VobjectState& state, Vobject* requester,
00042                                         const std::string& oldname, const std::string& newname) { };
00043 
00044         virtual void pre_getMyIdentity(VUtil::vRef<Identity>& myIdentity) { };
00045         virtual void post_setPeerIdentity(VUtil::vRef<Identity> peerIdentity) { };
00046 
00047         virtual void doSendMessage(VobjectState& state, Message* m) { };
00048         virtual void doSendMessage(VobjectState& state, MessageBlock* m) { };
00049     };
00050 }
00051 
00052 #endif