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

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

Go to the documentation of this file.
00001 /*
00002     This file is part of the Virtual Object System of
00003     the Interreality project (http://interreality.org).
00004 
00005     Copyright (C) 2001-2003 Peter Amstutz
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020 
00021     Peter Amstutz <http://www.interreality.org>
00022 */
00023 #ifndef _METAOBJECT_HH_
00024 #define _METAOBJECT_HH_
00025 
00026 #include <stdexcept>
00027 #include <typeinfo>
00028 
00029 namespace VOS
00030 {
00031 #ifndef SWIG
00032     class MetaObject;
00033 #endif
00034 }
00035 
00036 #include <vos/vos/vosdefs.hh>
00037 #include <vos/vos/vobject.hh>
00038 
00039 namespace VOS
00040 {
00041 #ifndef SWIG
00042     class VobjectBase;
00043 #endif
00044 
00045 /** @class MetaObject metaobject.hh vos/vos/metaobject.hh
00046     @ingroup libvos
00047 
00048     This class forwards every method in the Vobject API to the
00049     VobjectBase that it is attached to.  This is primarily useful for
00050     allowing subclasses of MetaObject to be usable as Vobjects in
00051     addition to adding their own API.  It also provides a couple of
00052     methods (VOS::MetaObject::doSaveState and VOS::MetaObject::doExcise)
00053     that can be overridden to provide custom behavior for those cases.
00054  */
00055 class VOS_API MetaObject : public virtual Vobject, public Dispatchable
00056 {
00057 private:
00058     VobjectBase* superobject;
00059 protected:
00060     MetaObject(VobjectBase* superobject);
00061 
00062     /** This is where you put type-handler specific save state code.
00063         @param output The messageblock to append your messages to
00064         @param types The types for the object that should be output as
00065         part of this save state. Some save state handlers may want to
00066         modify this.
00067         @param portable If true, generate a "portable" state.  This
00068         means that all the data required to restore state should be
00069         embedded in the message.  If false, fully recreating the state
00070         may rely on external resources such as files or databases.
00071         @see Vobject::saveState
00072     */
00073     virtual void doSaveState(MessageBlock& output, std::set<std::string>& types, bool portable);
00074 
00075     /** This is where you put type-handler specific code to respond to an excise().
00076         It will be called exactly once.
00077     */
00078     virtual void doExcise();
00079     virtual void doInitialize();
00080 
00081 public:
00082     /** destructor */
00083     virtual ~MetaObject();
00084 
00085     /** @returns the specific VOS type name that represents the VOS
00086         interface this object is supplying.  This should always be
00087         overridden by the subclass.
00088     */
00089     virtual const std::string getVOSType();
00090 
00091     virtual const std::string& getSiteName() const;
00092     virtual VUtil::vRef<Site> getSite() const;
00093     virtual const VUtil::URL& getURL() const;
00094     virtual bool isLocal();
00095     virtual bool isRemote();
00096     virtual TypeSetIterator getTypes();
00097     virtual void addType(const std::string& s);
00098     virtual void removeType(const std::string& s);
00099     virtual ParentSetIterator getParents();
00100     virtual ChildListIterator getChildren(int start = 0, int end = -1);
00101     virtual int numChildren();
00102 
00103     virtual void sendMessage(Message* m);
00104     virtual void sendMessage(MessageBlock* m);
00105     virtual void sendUpdateMessage(Message* m);
00106 
00107     virtual VUtil::vRef<Vobject> findObject(const std::string& path);
00108     virtual VUtil::vRef<ParentChildRelation> findChild(const std::string& path);
00109     virtual VUtil::vRef<ParentChildRelation> findChild(int pos);
00110     virtual VUtil::vRef<ParentChildRelation> findParent(Vobject* parent);
00111     virtual void setChild(int position, const std::string& contextual_name, Vobject* child);
00112     virtual void insertChild(int position, const std::string& contextual_name, Vobject* child);
00113     virtual void removeChild(ParentChildRelation* pcr, bool strict = true);
00114 
00115     virtual void addTypeListener(TypeChangeListener* tl, bool refresh = true);
00116     virtual void addParentListener(ParentChangeListener* pl, bool refresh = true);
00117     virtual void addChildListener(ChildChangeListener* cl, bool refresh = true);
00118     virtual void removeTypeListener(TypeChangeListener* tl);
00119     virtual void removeParentListener(ParentChangeListener* pl);
00120     virtual void removeChildListener(ChildChangeListener* cl);
00121 
00122     virtual void saveState(MessageBlock& output, std::set<std::string>& types, bool portable);
00123 
00124     virtual void addFlag(const std::string& flag);
00125     virtual void removeFlag(const std::string& flag);
00126     virtual bool checkFlag(const std::string& flag);
00127 
00128     /** @note Important: this is delegated to the top object, and
00129         means you want the entire logical Vobject to go away!  If
00130         called on an object with no superobject, it calls doExcise() on its type
00131         handlers.  Type implementation specific cleanup code (such as
00132         calling excise on certain children no longer needed) should
00133         override doExcise().
00134     */
00135     virtual void excise();
00136 
00137     /** Note that this is for the logical Vobject and not the specific
00138         MetaObject instance, i.e. it's forwarded to the VobjectBase
00139         just like everything else. */
00140     virtual void acquire();
00141 
00142     /** Note that this is for the logical Vobject and not the specific
00143         MetaObject instance, i.e. it's forwarded to the VobjectBase
00144         just like everything else. */
00145     virtual void release();
00146 
00147     /** Note that this is for the logical Vobject and not the specific
00148         MetaObject instance, i.e. it's forwarded to the VobjectBase
00149         just like everything else. */
00150     virtual int getRefCount();
00151 
00152     virtual VUtil::vRef<VobjectBase> getVobjectBase();
00153 
00154     virtual StringIterator getPolicy(const std::string& domain, Identity* id);
00155     StringIterator getAvailablePolicies(const std::string& domain);
00156 
00157     virtual void addToACL(const std::string& ACLname, Identity* id);
00158     virtual void addToACL(const std::string& ACLname, Group* grp);
00159 
00160     virtual void removeFromACL(const std::string& ACLname, Identity* id);
00161     virtual void removeFromACL(const std::string& ACLname, Group* grp);
00162 
00163     virtual void deleteACL(const std::string& policies);
00164 
00165     virtual std::string getDefaultPolicy(const std::string& domain = "");
00166     virtual void setDefaultPolicy(const std::string& policy);
00167 
00168     virtual ACLIterator getAllACLs();
00169 
00170     friend class VobjectBase;
00171 };
00172 
00173 }
00174 
00175 #endif