DefinedObjectContainer.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 
00019 
00020 #ifndef _DWFTK_DEFINED_OBJECT_CONTAINER_H
00021 #define _DWFTK_DEFINED_OBJECT_CONTAINER_H
00022 
00027 
00028 
00029 #include "dwf/Toolkit.h"
00030 #include "dwf/package/DefinedObject.h"
00031 #include "dwf/package/utility/PropertyContainer.h"
00032 
00033 namespace DWFToolkit
00034 {
00035 
00043 class DWFDefinedObjectContainer     _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE
00044 {
00045 
00046 public:
00047 
00053     _DWFTK_API
00054     DWFDefinedObjectContainer()
00055         throw();
00056 
00062     _DWFTK_API
00063     virtual ~DWFDefinedObjectContainer()
00064         throw();
00065 
00080     _DWFTK_API
00081     void addObject( DWFDefinedObject* pObject, uint32_t nKey = 0 )
00082         throw();
00083 
00092     _DWFTK_API
00093     void removeObject( DWFDefinedObject* pObject )
00094         throw();
00095 
00103     _DWFTK_API
00104     DWFDefinedObject* findObject( const DWFString& zID )
00105         throw( DWFException );
00106 
00113     _DWFTK_API
00114     bool empty() const
00115         throw();
00116 
00124     _DWFTK_API
00125     DWFPropertyContainer& getObjectProperties()
00126         throw();
00127 
00128 #ifndef DWFTK_READ_ONLY
00129 
00137     DWFXMLSerializable& getSerializableObjectContainer() const
00138         throw()
00139     {
00140         return (DWFXMLSerializable&)_oSerializer;
00141     }
00142 
00143 #endif
00144 
00145 #ifndef DWFTK_READ_ONLY
00146 
00147 private:
00148 
00149     //
00150     // in order to avoid bizarre diamond patterns and
00151     // excessively overload base implementations,
00152     // all container classes must define and implementation this
00153     // internal [PRIVATE] class utility for serializing themselves into XML.
00154     //
00155     class _Serializer : public DWFXMLSerializable
00156                         _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00157     {
00158 
00159     public:
00160 
00161         _Serializer()
00162             throw()
00163             : DWFXMLSerializable()
00164             , _pContainer( NULL )
00165         {;}
00166 
00167         virtual ~_Serializer()
00168             throw()
00169         {;}
00170 
00171         void is( DWFDefinedObjectContainer* pContainer )
00172         {
00173             _pContainer = pContainer;
00174         }
00175 
00176         //
00177         //
00178         //
00179         virtual void serializeXML( DWFXMLSerializer& rSerializer, unsigned int nFlags )
00180             throw( DWFException );
00181 
00182     private:
00183 
00184         DWFDefinedObjectContainer* _pContainer;
00185     };
00186 
00187 private:
00188 
00189     _Serializer                 _oSerializer;
00190 
00191 #endif
00192 
00193 
00194 protected:
00195 
00199     DWFDefinedObject::tMap  _oKeyedObjects;
00203     DWFPropertyContainer    _oObjectProperties;
00204 
00208     typedef std::multimap<uint32_t, DWFDefinedObject*>   _tGroupedObjectMap;
00212     _tGroupedObjectMap      _oGroupedObjects;
00213 
00214 private:
00215 
00216     DWFDefinedObjectContainer( const DWFDefinedObjectContainer& );
00217     DWFDefinedObjectContainer& operator=( const DWFDefinedObjectContainer& );
00218 };
00219 
00220 
00228 
00229 class DWFDefinedObjectInstanceContainer _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE
00230 {
00231 
00232 public:
00233 
00239     _DWFTK_API
00240     DWFDefinedObjectInstanceContainer()
00241         throw();
00242 
00248     _DWFTK_API
00249     virtual ~DWFDefinedObjectInstanceContainer()
00250         throw();
00251 
00266     _DWFTK_API
00267     void addInstance( DWFDefinedObjectInstance* pInstance, uint32_t nKey = 0 )
00268         throw();
00269 
00278     _DWFTK_API
00279     void removeInstance( DWFDefinedObjectInstance* pInstance )
00280         throw();
00281 
00288     _DWFTK_API
00289     bool empty() const
00290         throw();
00291 
00292 #ifndef DWFTK_READ_ONLY
00293 
00301     DWFXMLSerializable& getSerializableInstanceContainer() const
00302         throw()
00303     {
00304         return (DWFXMLSerializable&)_oSerializer;
00305     }
00306 
00307 #endif
00308 
00309 
00310 #ifndef DWFTK_READ_ONLY
00311 
00312 private:
00313 
00314     //
00315     // in order to avoid bizarre diamond patterns and
00316     // excessively overload base implementations,
00317     // all container classes must define and implementation this
00318     // internal [PRIVATE] class utility for serializing themselves into XML.
00319     //
00320     class _Serializer : public DWFXMLSerializable
00321                         _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00322     {
00323 
00324     public:
00325 
00326         _Serializer()
00327             throw()
00328             : DWFXMLSerializable()
00329             , _pContainer( NULL )
00330         {;}
00331 
00332         virtual ~_Serializer()
00333             throw()
00334         {;}
00335 
00336         void is( DWFDefinedObjectInstanceContainer* pContainer )
00337         {
00338             _pContainer = pContainer;
00339         }
00340 
00341         //
00342         //
00343         //
00344         virtual void serializeXML( DWFXMLSerializer& rSerializer, unsigned int nFlags )
00345             throw( DWFException );
00346 
00347     private:
00348 
00349         DWFDefinedObjectInstanceContainer* _pContainer;
00350     };
00351 
00352 private:
00353 
00354     _Serializer _oSerializer;
00355 
00356 #endif
00357 
00358 
00359 protected:
00360 
00364     typedef std::multimap<uint32_t, DWFDefinedObjectInstance*>   _tGroupedInstanceMap;
00368     _tGroupedInstanceMap    _oGroupedInstances;
00369 
00370 private:
00371 
00372     DWFDefinedObjectInstanceContainer( const DWFDefinedObjectInstanceContainer& );
00373     DWFDefinedObjectInstanceContainer& operator=( const DWFDefinedObjectInstanceContainer& );
00374 };
00375 
00376 }
00377 
00378 #endif

Generated on Tue Jan 6 22:40:03 2009 for Autodesk DWF Toolkit by  doxygen 1.4.5