Field3D
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
ClassFactory.h
Go to the documentation of this file.
1
//----------------------------------------------------------------------------//
2
3
/*
4
* Copyright (c) 2009 Sony Pictures Imageworks Inc
5
*
6
* All rights reserved.
7
*
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
10
* are met:
11
*
12
* Redistributions of source code must retain the above copyright
13
* notice, this list of conditions and the following disclaimer.
14
* Redistributions in binary form must reproduce the above copyright
15
* notice, this list of conditions and the following disclaimer in the
16
* documentation and/or other materials provided with the
17
* distribution. Neither the name of Sony Pictures Imageworks nor the
18
* names of its contributors may be used to endorse or promote
19
* products derived from this software without specific prior written
20
* permission.
21
*
22
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33
* OF THE POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
//----------------------------------------------------------------------------//
37
42
//----------------------------------------------------------------------------//
43
44
#ifndef _INCLUDED_Field3D_ClassFactory_H_
45
#define _INCLUDED_Field3D_ClassFactory_H_
46
47
#include <map>
48
#include <vector>
49
50
#include "
Field.h
"
51
#include "
FieldIO.h
"
52
#include "
FieldMappingIO.h
"
53
54
//----------------------------------------------------------------------------//
55
56
#include "
ns.h
"
57
58
FIELD3D_NAMESPACE_OPEN
59
60
//----------------------------------------------------------------------------//
61
// ClassFactory
62
//----------------------------------------------------------------------------//
63
68
//----------------------------------------------------------------------------//
69
70
class
ClassFactory
71
{
72
73
public
:
74
75
// Typedefs ------------------------------------------------------------------
76
77
typedef
FieldRes::Ptr
(*
CreateFieldFnPtr
) ();
78
typedef
FieldIO::Ptr
(*
CreateFieldIOFnPtr
) ();
79
typedef
FieldMapping::Ptr
(*
CreateFieldMappingFnPtr
) ();
80
typedef
FieldMappingIO::Ptr
(*
CreateFieldMappingIOFnPtr
) ();
81
82
// Ctors, dtor ---------------------------------------------------------------
83
85
ClassFactory
();
86
87
// Main methods --------------------------------------------------------------
88
91
94
void
registerField
(
CreateFieldFnPtr
createFunc);
95
97
FieldRes::Ptr
createField
(
const
std::string &className)
const
;
98
101
void
registerFieldIO
(
CreateFieldIOFnPtr
createFunc);
102
104
FieldIO::Ptr
createFieldIO
(
const
std::string &className)
const
;
105
107
110
113
void
registerFieldMapping
(
CreateFieldMappingFnPtr
createFunc);
114
116
FieldMapping::Ptr
createFieldMapping
(
const
std::string &className)
const
;
117
120
void
registerFieldMappingIO
(
CreateFieldMappingIOFnPtr
createFunc);
121
123
FieldMappingIO::Ptr
createFieldMappingIO
(
const
std::string &className)
const
;
124
126
128
static
ClassFactory
&
singleton
();
129
130
private
:
131
132
// Typedefs ------------------------------------------------------------------
133
134
typedef
std::vector<std::string>
NameVec
;
135
typedef
std::map<std::string, CreateFieldFnPtr>
FieldFuncMap
;
136
typedef
std::map<std::string, CreateFieldIOFnPtr>
FieldIOFuncMap
;
137
typedef
std::map<std::string, CreateFieldMappingFnPtr>
FieldMappingFuncMap
;
138
typedef
std::map<std::string, CreateFieldMappingIOFnPtr>
FieldMappingIOFuncMap
;
139
140
// Data members --------------------------------------------------------------
141
143
FieldFuncMap
m_fields
;
145
NameVec
m_fieldNames
;
146
148
FieldIOFuncMap
m_fieldIOs
;
150
NameVec
m_fieldIONames
;
151
153
FieldMappingFuncMap
m_mappings
;
155
NameVec
m_fieldMappingNames
;
156
159
FieldMappingIOFuncMap
m_mappingIOs
;
161
NameVec
m_fieldMappingIONames
;
162
164
static
ClassFactory
*
ms_instance
;
165
166
};
167
168
//----------------------------------------------------------------------------//
169
170
FIELD3D_NAMESPACE_HEADER_CLOSE
171
172
//----------------------------------------------------------------------------//
173
174
#endif // Include guard
export
ClassFactory.h
Generated on Wed Jul 11 2012 19:20:03 for Field3D by
1.8.1.1