1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGFIELDDESCFACTORY_H_
40 #define _OSGFIELDDESCFACTORY_H_
45 #include "OSGBaseTypes.h"
46 #include "OSGFactoryBase.h"
47 #include "OSGSingletonHolder.h"
48 #include "OSGFieldDescriptionBase.h"
58 /*! \ingroup GrpBaseField
59 \ingroup GrpLibOSGBase
62 class OSG_BASE_DLLMAPPING FieldDescFactoryBase
: public FactoryBase
64 /*========================== PUBLIC =================================*/
68 static const UInt32 AutoFlags
= 0xFF000000;
70 /*---------------------------------------------------------------------*/
71 /*! \name Destructor */
75 /*---------------------------------------------------------------------*/
79 Field
*createField( UInt32 typeId
);
80 Field
*createField(const Char8
*szName
);
83 /*---------------------------------------------------------------------*/
87 static UInt32
getNumFieldTypes (void );
89 static FieldType
*getFieldType ( UInt32 typeId
);
90 static FieldType
*getFieldType (const Char8
*szName
);
92 const Char8
*getFieldTypeName (UInt32 typeId
);
95 /*---------------------------------------------------------------------*/
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
);
129 /*========================= PROTECTED ===============================*/
133 typedef FactoryBase Inherited
;
136 /*---------------------------------------------------------------------*/
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
,
155 FieldDescCreator fCreator
,
156 IndexedFieldDescCreator fIdxCreator
);
158 /*---------------------------------------------------------------------*/
159 /*! \name Constructors */
162 FieldDescFactoryBase(void);
163 virtual ~FieldDescFactoryBase(void);
166 /*---------------------------------------------------------------------*/
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);
178 /*========================== PRIVATE ================================*/
182 template <class SingletonT
>
183 friend class SingletonHolder
;
186 friend class FieldType
;
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
);
199 template class OSG_BASE_DLLMAPPING SingletonHolder
<FieldDescFactoryBase
>;
202 /*! \typedef OSG::SingletonHolder<OSG::FieldDescFactoryBase> FieldDescFactory;
203 \ingroup GrpBaseField
204 \relatesalso OSG::FieldDescFactoryBase
207 typedef OSG::SingletonHolder
<OSG::FieldDescFactoryBase
> FieldDescFactory
;
211 #endif /* _OSGFIELDDESCFACTORY_H_ */