CrystalSpace

Public API Reference

iutil/object.h
Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2000 by Jorrit Tyberghein
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_IOBJECT_OBJECT_H__
00020 #define __CS_IOBJECT_OBJECT_H__
00021 
00027 #include "csutil/scf.h"
00028 #include "csutil/scf_interface.h"
00029 #include "csutil/ref.h"
00030 
00031 struct iObjectIterator;
00032 struct iObject;
00033 
00038 struct iObjectNameChangeListener : public virtual iBase
00039 {
00040   SCF_INTERFACE (iObjectNameChangeListener, 0, 0, 1);
00041 
00043   virtual void NameChanged (iObject* obj, const char* oldname,
00044         const char* newname) = 0;
00045 };
00046 
00047 
00063 struct iObject : public virtual iBase
00064 {
00065   SCF_INTERFACE(iObject,2,0,2);
00066 
00068   virtual void SetName (const char *iName) = 0;
00069 
00071   virtual const char *GetName () const = 0;
00072 
00074   virtual uint GetID () const = 0;
00075 
00080   virtual void SetObjectParent (iObject *obj) = 0;
00081 
00083   virtual iObject* GetObjectParent () const = 0;
00084 
00086   virtual void ObjAdd (iObject *obj) = 0;
00087 
00089   virtual void ObjRemove (iObject *obj) = 0;
00090 
00092   virtual void ObjRemoveAll () = 0;
00093 
00095   virtual void ObjAddChildren (iObject *Parent) = 0;
00096 
00107   CS_DEPRECATED_METHOD_MSG("Use GetChild(const char*) if you need \"first\" "
00108     "functionality, GetChild(int, int, const char*) otherwise.")
00109   virtual iObject* GetChild (int iInterfaceID, int iVersion,
00110     const char *Name, bool FirstName) const = 0;
00111 
00113   virtual iObject* GetChild (const char *Name) const = 0;
00114 
00119   virtual csPtr<iObjectIterator> GetIterator () = 0;
00120 
00122   virtual void ObjReleaseOld (iObject *obj) = 0;
00123 
00127   virtual void AddNameChangeListener (
00128         iObjectNameChangeListener* listener) = 0;
00129 
00133   virtual void RemoveNameChangeListener (
00134         iObjectNameChangeListener* listener) = 0;
00135   
00140   virtual iObject* GetChild (int iInterfaceID, int iVersion,
00141     const char *Name = 0) const = 0;
00142 
00143 };
00144 
00145 
00156 struct iObjectIterator : public virtual iBase
00157 {
00158   SCF_INTERFACE(iObjectIterator,2,0,0);
00160   virtual iObject* Next () = 0;
00161 
00163   virtual void Reset () = 0;
00164 
00166   virtual iObject* GetParentObj () const = 0;
00167 
00169   virtual bool HasNext () const = 0;
00170 
00177   virtual iObject* FindName (const char* name) = 0;
00178 };
00179 
00180 namespace CS
00181 {
00185   template<typename Interface>
00186   static inline csPtr<Interface> GetChildObject (iObject* object)
00187   {
00188     return scfQueryInterfaceSafe<Interface> (object->GetChild (
00189       scfInterfaceTraits<Interface>::GetID(),
00190       scfInterfaceTraits<Interface>::GetVersion()));
00191   }
00192 
00197   template<typename Interface>
00198   static inline csPtr<Interface> GetNamedChildObject (iObject* object,
00199                                                       const char* name)
00200   {
00201     return scfQueryInterfaceSafe<Interface> (object->GetChild (scfInterfaceTraits<Interface>::GetID(),
00202                                              scfInterfaceTraits<Interface>::GetVersion(), name));
00203   }
00204 }
00205 
00206 template<typename Interface>
00207 inline CS_DEPRECATED_METHOD_MSG ("CS_GET_CHILD_OBJECT macro is deprecated, "
00208                                  "use CS::GetChildObject() instead")
00209 csPtr<Interface> CS_GET_CHILD_OBJECT_is_deprecated (iObject* Object)
00210 {
00211   return CS::GetChildObject<Interface> (Object);
00212 }
00217 #define CS_GET_CHILD_OBJECT(Object, Interface) \
00218   (CS_GET_CHILD_OBJECT_is_deprecated<Interface> (Object))
00219 
00220 template<typename Interface>
00221 inline CS_DEPRECATED_METHOD_MSG ("CS_GET_NAMED_CHILD_OBJECT macro is deprecated, "
00222                                  "use CS::GetNamedChildObject() instead")
00223 csPtr<Interface> CS_GET_NAMED_CHILD_OBJECT_is_deprecated (iObject* Object,
00224   const char* Name)
00225 {
00226   return CS::GetNamedChildObject<Interface> (Object, Name);
00227 }
00233 #define CS_GET_NAMED_CHILD_OBJECT(Object, Interface, Name) \
00234   (CS_GET_NAMED_CHILD_OBJECT_is_deprecated<Interface> (Object, Name))
00235 
00236 template<typename Interface>
00237 inline CS_DEPRECATED_METHOD_MSG ("CS_GET_FIRST_NAMED_CHILD_OBJECT macro is deprecated, "
00238                                  "use iObject->GetChild() and scfQueryInterface() ")
00239 csPtr<Interface> CS_GET_FIRST_NAMED_CHILD_OBJECT_is_deprecated (iObject* Object,
00240   const char* Name)
00241 {
00242   return scfQueryInterfaceSafe<Interface> (Object->GetChild (Name));
00243 }
00248 #define CS_GET_FIRST_NAMED_CHILD_OBJECT(Object, Interface, Name) \
00249   (CS_GET_FIRST_NAMED_CHILD_OBJECT_is_deprecated<Interface> (Object, Name))
00250 
00253 #endif // __CS_IOBJECT_OBJECT_H__

Generated for Crystal Space 2.0 by doxygen 1.7.6.1