fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Base / Field / OSGFieldDescFactory.h
blob4a1976b2292b5ca6f9e4546a1c91d0f0be570af3
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGFIELDDESCFACTORY_H_
40 #define _OSGFIELDDESCFACTORY_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGBaseTypes.h"
46 #include "OSGFactoryBase.h"
47 #include "OSGSingletonHolder.h"
48 #include "OSGFieldDescriptionBase.h"
50 #include <map>
51 #include <vector>
53 OSG_BEGIN_NAMESPACE
55 class Field;
56 class FieldType;
58 /*! \ingroup GrpBaseField
59 \ingroup GrpLibOSGBase
62 class OSG_BASE_DLLMAPPING FieldDescFactoryBase : public FactoryBase
64 /*========================== PUBLIC =================================*/
66 public:
68 static const UInt32 AutoFlags = 0xFF000000;
70 /*---------------------------------------------------------------------*/
71 /*! \name Destructor */
72 /*! \{ */
74 /*! \} */
75 /*---------------------------------------------------------------------*/
76 /*! \name Create */
77 /*! \{ */
79 Field *createField( UInt32 typeId);
80 Field *createField(const Char8 *szName);
82 /*! \} */
83 /*---------------------------------------------------------------------*/
84 /*! \name Get */
85 /*! \{ */
87 static UInt32 getNumFieldTypes (void );
89 static FieldType *getFieldType ( UInt32 typeId);
90 static FieldType *getFieldType (const Char8 *szName);
92 const Char8 *getFieldTypeName (UInt32 typeId );
94 /*! \} */
95 /*---------------------------------------------------------------------*/
96 /*! \name The */
97 /*! \{ */
99 FieldDescriptionBase *
100 createByName (const Char8 *szFieldTypename,
101 const Char8 *szFieldname,
102 FieldEditMethod fEditMethod,
103 FieldGetMethod fGetMethod,
104 UInt32 uiFieldFlags = AutoFlags);
106 FieldDescriptionBase *
107 createByNameIdx(const Char8 *szFieldTypename,
108 const Char8 *szFieldname,
109 FieldIndexEditMethod fEditMethod,
110 FieldIndexGetMethod fGetMethod,
111 UInt32 uiFieldFlags = AutoFlags);
114 FieldDescriptionBase *
115 create ( UInt32 uiFieldTypeId,
116 const Char8 *szFieldname,
117 FieldEditMethod fEditMethod,
118 FieldGetMethod fGetMethod,
119 UInt32 uiFieldFlags = AutoFlags);
121 FieldDescriptionBase *
122 createIdx( UInt32 uiFieldTypeId,
123 const Char8 *szFieldname,
124 FieldIndexEditMethod fEditMethod,
125 FieldIndexGetMethod fGetMethod,
126 UInt32 uiFieldFlags = AutoFlags);
128 /*! \} */
129 /*========================= PROTECTED ===============================*/
131 protected:
133 typedef FactoryBase Inherited;
136 /*---------------------------------------------------------------------*/
137 /* Member */
139 typedef std::pair<FieldDescCreator,
140 IndexedFieldDescCreator> DescCreators;
141 typedef std::map <std::string,
142 DescCreators > NameCreatorMap;
143 typedef std::map <std::string,
144 DescCreators >::iterator NameCreatorMapIt;
145 typedef std::map <std::string,
146 DescCreators >::const_iterator NameCreatorMapConstIt;
148 typedef std::vector<DescCreators > CreatorStore;
150 NameCreatorMap _mNameCreatorMap;
151 CreatorStore _vCreators;
153 void registerDescription(const Char8 *szFieldTypename,
154 UInt32 uiTypeId,
155 FieldDescCreator fCreator,
156 IndexedFieldDescCreator fIdxCreator );
158 /*---------------------------------------------------------------------*/
159 /*! \name Constructors */
160 /*! \{ */
162 FieldDescFactoryBase(void);
163 virtual ~FieldDescFactoryBase(void);
165 /*! \} */
166 /*---------------------------------------------------------------------*/
167 /* Member */
169 virtual bool initialize (void);
170 virtual bool terminate (void);
172 virtual bool initializePendingElements (void);
174 virtual bool initializeFactoryPost (void);
175 virtual bool initializePendingElementsFactoryPost(void);
177 /*! \} */
178 /*========================== PRIVATE ================================*/
180 private:
182 template <class SingletonT>
183 friend class SingletonHolder;
186 friend class FieldType;
187 friend class Field;
189 /*---------------------------------------------------------------------*/
191 /*!\brief prohibit default function (move to 'public' if needed) */
192 FieldDescFactoryBase(const FieldDescFactoryBase &source);
193 /*!\brief prohibit default function (move to 'public' if needed) */
194 void operator =(const FieldDescFactoryBase &source);
197 #if defined(WIN32)
198 OSG_BASE_EXPIMP_TMPL
199 template class OSG_BASE_DLLMAPPING SingletonHolder<FieldDescFactoryBase>;
200 #endif
202 /*! \typedef OSG::SingletonHolder<OSG::FieldDescFactoryBase> FieldDescFactory;
203 \ingroup GrpBaseField
204 \relatesalso OSG::FieldDescFactoryBase
207 typedef OSG::SingletonHolder<OSG::FieldDescFactoryBase> FieldDescFactory;
209 OSG_END_NAMESPACE
211 #endif /* _OSGFIELDDESCFACTORY_H_ */