Wolframe, 0.0.3

cppFormFunction.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_serialize_CPP_FORM_FUNCTION_HPP_INCLUDED
35 #define _Wolframe_serialize_CPP_FORM_FUNCTION_HPP_INCLUDED
36 #include "serialize/flags.hpp"
43 #include "filter/typedfilter.hpp"
44 #include <boost/shared_ptr.hpp>
45 
46 namespace _Wolframe {
47 namespace serialize {
48 
49 class CppFormFunction;
50 
54 {
55 public:
59  ~ApiFormData();
60 
62  void* get() const {return m_data.get();}
66  const boost::shared_ptr<void>& data() const {return m_data;}
67 private:
69  boost::shared_ptr<void> m_data;
70 };
71 
76 {
77 public:
81 
85 
88  bool call();
89 
95 
97  virtual langbind::TypedInputFilterR result() const {return m_result;}
98 
99 private:
101  int m_state;
107 };
108 
112  :public langbind::FormFunction
113 {
114 public:
115  typedef int (*Function)( proc::ExecContext* ctx, void* res, const void* param);
116 
119  :m_function(0)
120  ,m_api_param(0)
121  ,m_api_result(0){}
122 
129 
135  :m_function(f)
136  ,m_api_param(p)
137  ,m_api_result(r)
138  {}
139 
143  {return m_api_param;}
144 
148  {return m_api_result;}
149 
155  int call( proc::ExecContext* ctx, void* res, const void* param) const
156  {return (*m_function)( ctx, res, param);}
157 
160  {
161  return new CppFormFunctionClosure( *this);
162  }
163 
164 private:
168 };
169 
171 typedef boost::shared_ptr<CppFormFunction> CppFormFunctionR;
172 
173 }}//namespace
174 #endif
175 
proc::ExecContext * m_context
execution context
Definition: cppFormFunction.hpp:106
Serialization interface.
Base class for structure description used for introspection in serialization/deserialization.
Definition: structDescriptionBase.hpp:51
Form function execution context interface.
Definition: formFunction.hpp:52
bool call()
Calls the form function with the input from the input filter specified.
Structure to hold an arbitrary C++ structure as owner defined by a serialization definition.
Definition: cppFormFunction.hpp:53
boost::shared_ptr< void > m_data
shared base pointer reference to the C++ structure
Definition: cppFormFunction.hpp:69
Initializer of a structure based on a structure description feeded with a serialization.
Definition: structParser.hpp:43
Execution context passed to functions for referencing resources and to define authorization dependend...
Definition: execContext.hpp:47
CppFormFunction()
Default constructor.
Definition: cppFormFunction.hpp:118
CppFormFunction(const CppFormFunction &o)
Copy constructor.
Definition: cppFormFunction.hpp:125
virtual langbind::TypedInputFilterR result() const
Get the result iterator reference of the function call.
Definition: cppFormFunction.hpp:97
const serialize::StructDescriptionBase * m_descr
serialization description of the C++ structure
Definition: cppFormFunction.hpp:68
Function m_function
form function implementation
Definition: cppFormFunction.hpp:165
int m_state
execution state
Definition: cppFormFunction.hpp:101
boost::shared_ptr< CppFormFunction > CppFormFunctionR
Shared form function reference.
Definition: cppFormFunction.hpp:171
int call(proc::ExecContext *ctx, void *res, const void *param) const
Call the form function.
Definition: cppFormFunction.hpp:155
Interface for executing functions with structure input/output in the language bindings.
const serialize::StructDescriptionBase * api_result() const
Get the form function result description.
Definition: cppFormFunction.hpp:147
boost::shared_ptr< TypedInputFilter > TypedInputFilterR
Shared input filter (langbind::TypedInputFilter) reference.
Definition: typedfilter.hpp:98
Interface to processor provider for language bindings and database.
Closure with calling state of called CppFormFunction.
Definition: cppFormFunction.hpp:74
Execution context.
Form function interface.
Definition: formFunction.hpp:78
const boost::shared_ptr< void > & data() const
Get the structure base pointer as shared reference.
Definition: cppFormFunction.hpp:66
CppFormFunctionClosure(const CppFormFunction &f)
Constructor.
ApiFormData m_param_data
parameter structure
Definition: cppFormFunction.hpp:102
Enum
the enumeration that can also be interpreted as bit set
Definition: flags.hpp:47
const serialize::StructDescriptionBase * m_api_result
result structure description
Definition: cppFormFunction.hpp:167
int(* Function)(proc::ExecContext *ctx, void *res, const void *param)
Definition: cppFormFunction.hpp:115
Deserialization interface.
ApiFormData m_result_data
result structure
Definition: cppFormFunction.hpp:103
Defines the flags for serialization behaviour.
const serialize::StructDescriptionBase * descr() const
Get the structure serialization description.
Definition: cppFormFunction.hpp:64
const CppFormFunction * m_func
the C++ form function implementation
Definition: cppFormFunction.hpp:100
CppFormFunction(Function f, const serialize::StructDescriptionBase *p, const serialize::StructDescriptionBase *r)
Constructor.
Definition: cppFormFunction.hpp:134
Defines the non intrusive base class of serialization/deserialization of objects interfaced as TypedI...
langbind::TypedInputFilterR m_result
result iterator
Definition: cppFormFunction.hpp:104
const serialize::StructDescriptionBase * api_param() const
Get the form function parameter description.
Definition: cppFormFunction.hpp:142
void init(proc::ExecContext *c, const langbind::TypedInputFilterR &i, serialize::Flags::Enum flags)
Initialization of call context for a new call.
const serialize::StructDescriptionBase * m_api_param
parameter structure description
Definition: cppFormFunction.hpp:166
Typed interface for input/output filter.
serialize::StructParser m_parser
input structure parser
Definition: cppFormFunction.hpp:105
Function of language bindings implemented in C++ with a form as argument and as result. The forms are defined by a serialization description.
Definition: cppFormFunction.hpp:111
virtual langbind::FormFunctionClosure * createClosure() const
Create the state machine context (called closure) for execution the function.
Definition: cppFormFunction.hpp:159
ApiFormData(const serialize::StructDescriptionBase *descr)
Constructor.