Wolframe, 0.0.3

customDataTypeBuilder.hpp
Go to the documentation of this file.
1 /************************************************************************
2 Copyright (C) 2011 - 2014 Project Wolframe.
3 All rights reserved.
4 
5 This file is part of Project Wolframe.
6 
7 Commercial Usage
8 Licensees holding valid Project Wolframe Commercial licenses may
9 use this file in accordance with the Project Wolframe
10 Commercial License Agreement provided with the Software or,
11 alternatively, in accordance with the terms contained
12 in a written agreement between the licensee and Project Wolframe.
13 
14 GNU General Public License Usage
15 Alternatively, you can redistribute this file and/or modify it
16 under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19 
20 Wolframe is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24 
25 You should have received a copy of the GNU General Public License
26 along with Wolframe. If not, see <http://www.gnu.org/licenses/>.
27 
28 If you have questions regarding the use of this file, please contact
29 Project Wolframe.
30 
31 ************************************************************************/
34 #ifndef _Wolframe_MODULE_CUSTOM_DATA_TYPE_BUILDER_HPP_INCLUDED
35 #define _Wolframe_MODULE_CUSTOM_DATA_TYPE_BUILDER_HPP_INCLUDED
37 #include "module/constructor.hpp"
38 #include "types/customDataType.hpp"
39 #include "types/keymap.hpp"
40 #include <string>
41 #include <cstring>
42 #include <stdexcept>
43 #include <boost/shared_ptr.hpp>
44 
45 namespace _Wolframe {
46 namespace module {
47 
51  :public SimpleObjectConstructor<types::CustomDataType>
52 {
53 public:
54  CustomDataTypeConstructor( const char* classname_, const std::string& identifier_, types::CreateCustomDataType createFunc_)
55  :m_classname(classname_)
56  {
57  types::CustomDataType* cdt = (*createFunc_)( identifier_);
58  m_datatype.reset( cdt);
59  }
60 
62 
64  {
66  }
67 
68  const std::string& identifier() const
69  {
70  return m_datatype->name();
71  }
72 
73  virtual const char* objectClassName() const
74  {
75  return m_classname;
76  }
77 
78  virtual types::CustomDataType* object() const
79  {
80  return new types::CustomDataType( *m_datatype);
81  }
82 
83 private:
84  const char* m_classname;
86 };
87 
88 typedef boost::shared_ptr<CustomDataTypeConstructor> CustomDataTypeConstructorR;
89 
90 
94 {
95 public:
96  CustomDataTypeBuilder( const char* classname_, const char* identifier_, types::CreateCustomDataType createFunc_)
97  :SimpleBuilder(classname_),m_identifier(identifier_),m_createFunc(createFunc_)
98  {}
99 
101 
103  {
105  }
106 
108  {
110  }
111 
112 private:
113  std::string m_identifier;
115 };
116 
117 }}//namespace
118 
119 #endif
120 
std::string m_identifier
Definition: customDataTypeBuilder.hpp:113
const std::string & identifier() const
Definition: customDataTypeBuilder.hpp:68
Base classes for virtual constructors to build objects loaded from modules.
Builder of a custom data type constructor for language bindings.
Definition: customDataTypeBuilder.hpp:93
Custom data type interface for variant.
virtual const char * objectClassName() const
Definition: customDataTypeBuilder.hpp:73
virtual types::CustomDataType * object() const
Definition: customDataTypeBuilder.hpp:78
types::CreateCustomDataType m_createFunc
Definition: customDataTypeBuilder.hpp:114
ObjectType
Definition: constructor.hpp:47
boost::shared_ptr< CustomDataType > CustomDataTypeR
Definition: customDataType.hpp:202
Basic interface classes that to build objects and the Wolframe module interface.
Constructor of a simple (without configuration) object.
Definition: constructor.hpp:116
Constructor of a custom data type for language bindings.
Definition: customDataTypeBuilder.hpp:50
virtual ObjectConstructorBase::ObjectType objectType() const
Definition: customDataTypeBuilder.hpp:102
virtual ~CustomDataTypeConstructor()
Definition: customDataTypeBuilder.hpp:61
Custom Data Type Definition.
Definition: customDataType.hpp:105
Base class for builders of objects without configuration.
Definition: moduleInterface.hpp:63
template for map with case insensitive key strings
virtual ObjectConstructorBase * constructor()
Definition: customDataTypeBuilder.hpp:107
boost::shared_ptr< CustomDataTypeConstructor > CustomDataTypeConstructorR
Definition: customDataTypeBuilder.hpp:88
Constructor base class.
Definition: constructor.hpp:44
CustomDataTypeConstructor(const char *classname_, const std::string &identifier_, types::CreateCustomDataType createFunc_)
Definition: customDataTypeBuilder.hpp:54
CustomDataTypeBuilder(const char *classname_, const char *identifier_, types::CreateCustomDataType createFunc_)
Definition: customDataTypeBuilder.hpp:96
virtual ObjectConstructorBase::ObjectType objectType() const
The type of the object. Filter, DDL compiler, authentication etc.
Definition: customDataTypeBuilder.hpp:63
const char * m_classname
Definition: customDataTypeBuilder.hpp:84
CustomDataType *(* CreateCustomDataType)(const std::string &name)
Definition: customDataType.hpp:205
types::CustomDataTypeR m_datatype
Definition: customDataTypeBuilder.hpp:85
virtual const char * objectClassName() const
Definition: moduleInterface.hpp:73
virtual ~CustomDataTypeBuilder()
Definition: customDataTypeBuilder.hpp:100