Wolframe, 0.0.3

normalizeFunction.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 
35 #ifndef _Wolframe_TYPES_NORMALIZE_FUNCTION_HPP_INCLUDED
36 #define _Wolframe_TYPES_NORMALIZE_FUNCTION_HPP_INCLUDED
37 #include <string>
38 #include <vector>
39 #include <cstring>
40 #include <stdexcept>
41 #include <boost/shared_ptr.hpp>
42 
43 namespace _Wolframe {
44 namespace types {
45 
48 class Variant;
49 
53 {
54 public:
55  virtual ~NormalizeFunction(){}
56  virtual const char* name() const=0;
57  virtual Variant execute( const Variant& i) const=0;
58  virtual NormalizeFunction* copy() const=0;
59 };
60 
62 typedef boost::shared_ptr<NormalizeFunction> NormalizeFunctionR;
63 
67 {
68 public:
71 };
72 
73 typedef boost::shared_ptr<NormalizeResourceHandle> NormalizeResourceHandleR;
74 
75 
76 typedef const NormalizeResourceHandleR& (*GetNormalizeResourceHandle)();
77 typedef NormalizeFunction* (*CreateNormalizeFunction)( NormalizeResourceHandle* reshnd, const std::vector<types::Variant>& arg);
78 
82 {
83 public:
85  :m_createFunction(c){}
87  :m_createFunction(c),m_resources(resources_){}
91 
92  NormalizeFunction* createFunction( const std::vector<types::Variant>& arg) const
93  {
94  if (m_createFunction)
95  {
96  return m_createFunction( m_resources.get(), arg);
97  }
98  else
99  {
100  return 0;
101  }
102 
103  }
104 private:
107 };
108 
109 
110 
111 
115 {
117  virtual const NormalizeFunction* get( const std::string& name) const=0;
118 };
119 
121 typedef boost::shared_ptr<NormalizeFunctionMap> NormalizeFunctionMapR;
122 
123 }}//namespace
124 #endif
125 
Class of basic normalization functions instantiated by arguments.
Definition: normalizeFunction.hpp:81
boost::shared_ptr< NormalizeFunctionMap > NormalizeFunctionMapR
Shared ownership reference to map of basic normalization functions for atomic values (variant type) ...
Definition: normalizeFunction.hpp:121
virtual ~NormalizeFunctionMap()
Definition: normalizeFunction.hpp:116
NormalizeFunction * createFunction(const std::vector< types::Variant > &arg) const
Definition: normalizeFunction.hpp:92
CreateNormalizeFunction m_createFunction
Definition: normalizeFunction.hpp:105
Base class for resources for normalization functions.
Definition: normalizeFunction.hpp:66
NormalizeFunction *(* CreateNormalizeFunction)(NormalizeResourceHandle *reshnd, const std::vector< types::Variant > &arg)
Definition: normalizeFunction.hpp:77
NormalizeResourceHandle()
Definition: normalizeFunction.hpp:69
virtual ~NormalizeFunction()
Definition: normalizeFunction.hpp:55
NormalizeResourceHandleR m_resources
Definition: normalizeFunction.hpp:106
Basic normalization function for atomic values (variant type)
Definition: normalizeFunction.hpp:52
virtual ~NormalizeResourceHandle()
Definition: normalizeFunction.hpp:70
Forward declaration.
Definition: variant.hpp:65
NormalizeFunctionType(CreateNormalizeFunction c=0)
Definition: normalizeFunction.hpp:84
boost::shared_ptr< NormalizeResourceHandle > NormalizeResourceHandleR
Definition: normalizeFunction.hpp:73
virtual const char * name() const =0
NormalizeFunctionType(CreateNormalizeFunction c, const NormalizeResourceHandleR &resources_)
Definition: normalizeFunction.hpp:86
~NormalizeFunctionType()
Definition: normalizeFunction.hpp:90
virtual NormalizeFunction * copy() const =0
Map of basic normalization functions for atomic values (variant type)
Definition: normalizeFunction.hpp:114
virtual Variant execute(const Variant &i) const =0
NormalizeFunctionType(const NormalizeFunctionType &o)
Definition: normalizeFunction.hpp:88
boost::shared_ptr< NormalizeFunction > NormalizeFunctionR
Shared ownership reference to normalization function for atomic values (variant type) ...
Definition: normalizeFunction.hpp:62