xoreos
0.0.5
src
aurora
nwscript
functionman.h
Go to the documentation of this file.
1
/* xoreos - A reimplementation of BioWare's Aurora engine
2
*
3
* xoreos is the legal property of its developers, whose names
4
* can be found in the AUTHORS file distributed with this source
5
* distribution.
6
*
7
* xoreos is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
11
*
12
* xoreos is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19
*/
20
25
#ifndef AURORA_NWSCRIPT_FUNCTIONMAN_H
26
#define AURORA_NWSCRIPT_FUNCTIONMAN_H
27
28
#include <vector>
29
#include <map>
30
31
#include "
src/common/ustring.h
"
32
#include "
src/common/singleton.h
"
33
34
#include "
src/aurora/nwscript/types.h
"
35
#include "
src/aurora/nwscript/functioncontext.h
"
36
37
namespace
Aurora
{
38
39
namespace
NWScript {
40
41
class
FunctionManager
:
public
Common::Singleton
<FunctionManager> {
42
public
:
43
44
FunctionManager
();
45
~FunctionManager
();
46
47
void
clear
();
48
49
void
registerFunction
(
const
Common::UString
&name,
uint32
id
,
const
Function
&func,
50
const
Signature
&signature);
51
void
registerFunction
(
const
Common::UString
&name,
uint32
id
,
const
Function
&func,
52
const
Signature
&signature,
const
Parameters
&defaults);
53
54
FunctionContext
createContext
(
const
Common::UString
&
function
)
const
;
55
void
call
(
const
Common::UString
&
function
,
FunctionContext
&ctx)
const
;
56
57
FunctionContext
createContext
(
uint32
function
)
const
;
58
void
call
(
uint32
function
,
FunctionContext
&ctx)
const
;
59
60
private
:
61
struct
FunctionEntry
{
62
bool
empty
;
63
64
Function
func
;
65
FunctionContext
ctx
;
66
67
FunctionEntry
(
const
Common::UString
&name =
""
);
68
};
69
70
typedef
std::map<Common::UString, FunctionEntry>
FunctionMap
;
71
typedef
std::vector<FunctionEntry>
FunctionArray
;
72
73
FunctionMap
_functionMap
;
74
FunctionArray
_functionArray
;
75
76
const
FunctionEntry
&
find
(
const
Common::UString
&
function
)
const
;
77
const
FunctionEntry
&
find
(
uint32
function
)
const
;
78
};
79
80
}
// End of namespace NWScript
81
82
}
// End of namespace Aurora
83
84
#define FunctionMan Aurora::NWScript::FunctionManager::instance()
85
86
#endif // AURORA_NWSCRIPT_FUNCTIONMAN_H
Aurora::NWScript::FunctionManager::FunctionEntry::ctx
FunctionContext ctx
Definition:
functionman.h:65
singleton.h
Class and macro for implementing singletons.
Aurora::NWScript::Parameters
std::vector< class Variable > Parameters
Definition:
types.h:54
Common::UString
A class holding an UTF-8 string.
Definition:
ustring.h:48
Aurora::NWScript::FunctionManager::FunctionManager
FunctionManager()
Definition:
functionman.cpp:42
Aurora::NWScript::FunctionManager::_functionMap
FunctionMap _functionMap
Definition:
functionman.h:73
functioncontext.h
Context of an NWScript function.
Aurora::NWScript::FunctionManager::FunctionEntry
Definition:
functionman.h:61
Aurora::NWScript::FunctionManager::FunctionEntry::func
Function func
Definition:
functionman.h:64
Aurora::NWScript::FunctionContext
Definition:
functioncontext.h:42
Aurora::NWScript::FunctionManager::call
void call(const Common::UString &function, FunctionContext &ctx) const
Definition:
functionman.cpp:87
Aurora::NWScript::FunctionManager::createContext
FunctionContext createContext(const Common::UString &function) const
Definition:
functionman.cpp:83
Common::Singleton
Generic template base class for implementing the singleton design pattern.
Definition:
singleton.h:61
Aurora
Definition:
2dafile.cpp:51
Aurora::NWScript::FunctionManager::_functionArray
FunctionArray _functionArray
Definition:
functionman.h:74
Aurora::NWScript::FunctionManager::FunctionEntry::FunctionEntry
FunctionEntry(const Common::UString &name="")
Definition:
functionman.cpp:37
Aurora::NWScript::Signature
std::vector< Type > Signature
Definition:
types.h:52
Aurora::NWScript::FunctionManager::FunctionMap
std::map< Common::UString, FunctionEntry > FunctionMap
Definition:
functionman.h:70
Aurora::NWScript::FunctionManager
Definition:
functionman.h:41
Aurora::NWScript::FunctionManager::FunctionArray
std::vector< FunctionEntry > FunctionArray
Definition:
functionman.h:71
Aurora::NWScript::FunctionManager::~FunctionManager
~FunctionManager()
Definition:
functionman.cpp:45
Aurora::NWScript::FunctionManager::FunctionEntry::empty
bool empty
Definition:
functionman.h:62
ustring.h
Unicode string handling.
Aurora::NWScript::FunctionManager::registerFunction
void registerFunction(const Common::UString &name, uint32 id, const Function &func, const Signature &signature)
Definition:
functionman.cpp:53
Aurora::NWScript::FunctionManager::find
const FunctionEntry & find(const Common::UString &function) const
Definition:
functionman.cpp:119
uint32
uint32_t uint32
Definition:
types.h:204
Aurora::NWScript::FunctionManager::clear
void clear()
Definition:
functionman.cpp:48
types.h
NWScript types.
Aurora::NWScript::Function
boost::function< void(class FunctionContext &ctx)> Function
Definition:
types.h:56
Generated on Sun Nov 18 2018 15:13:38 for xoreos by
1.8.14