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 #ifndef __CS_IUTIL_OBJREG_H__
00020 #define __CS_IUTIL_OBJREG_H__
00021
00030 #include "csutil/ref.h"
00031 #include "csutil/scf_interface.h"
00032
00033 struct iObjectRegistryIterator;
00034
00048 struct iObjectRegistry : public virtual iBase
00049 {
00050 SCF_INTERFACE(iObjectRegistry, 2,0,0);
00051
00052 CS_IMPLEMENT_IMPLICIT_PTR_CAST (iObjectRegistry);
00053
00057 virtual void Clear () = 0;
00058
00075 virtual bool Register (iBase* obj, char const* tag = 0) = 0;
00076
00088 virtual void Unregister (iBase* obj, char const* tag = 0) = 0;
00089
00096 virtual iBase* Get (char const* tag) = 0;
00097
00105 virtual iBase* Get (char const* tag, scfInterfaceID id, int version) = 0;
00106
00113 virtual csPtr<iObjectRegistryIterator> Get (
00114 scfInterfaceID id, int version) = 0;
00115
00122 virtual csPtr<iObjectRegistryIterator> Get () = 0;
00123 };
00124
00125
00130 struct iObjectRegistryIterator : public virtual iBase
00131 {
00132 SCF_INTERFACE(iObjectRegistryIterator, 2,0,0);
00137 virtual bool Reset () = 0;
00138
00142 virtual const char* GetCurrentTag () = 0;
00143
00147 virtual bool HasNext () = 0;
00148
00152 virtual iBase* Next () = 0;
00153 };
00154
00160 template<class Interface>
00161 inline csPtr<Interface> csQueryRegistry (iObjectRegistry *Reg)
00162 {
00163 iBase *base = Reg->Get (scfInterfaceTraits<Interface>::GetName (),
00164 scfInterfaceTraits<Interface>::GetID (),
00165 scfInterfaceTraits<Interface>::GetVersion ());
00166
00167 if (base == 0) return csPtr<Interface> (0);
00168
00169 Interface *x = (Interface*)base->QueryInterface (
00170 scfInterfaceTraits<Interface>::GetID (),
00171 scfInterfaceTraits<Interface>::GetVersion ());
00172
00173 if (x) base->DecRef ();
00174 return csPtr<Interface> (x);
00175 }
00176
00180 inline csPtr<iBase> csQueryRegistryTag (iObjectRegistry *Reg, const char* Tag)
00181 {
00182 return csPtr<iBase> (Reg->Get (Tag));
00183 }
00184
00188 template<class Interface>
00189 inline csPtr<Interface> csQueryRegistryTagInterface (
00190 iObjectRegistry *Reg, const char* Tag)
00191 {
00192 iBase *base = Reg->Get (Tag,
00193 scfInterfaceTraits<Interface>::GetID (),
00194 scfInterfaceTraits<Interface>::GetVersion ());
00195
00196 if (base == 0) return csPtr<Interface> (0);
00197
00198 Interface *x = (Interface*)base->QueryInterface (
00199 scfInterfaceTraits<Interface>::GetID (),
00200 scfInterfaceTraits<Interface>::GetVersion ());
00201
00202 if (x) base->DecRef ();
00203 return csPtr<Interface> (x);
00204 }
00205
00206 #endif // __CS_IUTIL_OBJREG_H__
00207