UGDK
0.4.1
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
langwrapper.h
Go to the documentation of this file.
1
2
#ifndef UGDK_SCRIPT_LANGWRAPPER_H_
3
#define UGDK_SCRIPT_LANGWRAPPER_H_
4
5
#include <string>
6
7
#include <
ugdk/script/defs.h
>
8
#include <
ugdk/script/type.h
>
9
#include <
ugdk/script/virtualdata.h
>
10
#include <
ugdk/script/module.h
>
11
12
namespace
ugdk {
13
namespace
script {
14
15
class
VirtualObj;
16
template
<
class
loader_t>
class
InheritableLangWrapper
;
17
18
class
LangWrapper
{
19
20
public
:
21
22
virtual
~LangWrapper
() {}
23
24
const
std::string&
file_extension
() {
return
file_extension_; }
25
26
28
31
virtual
bool
Initialize
() = 0;
32
34
virtual
void
Finalize
() = 0;
35
36
virtual
VirtualData::Ptr
NewData
() = 0;
37
38
virtual
void
ExecuteCode
(
const
std::string& code) = 0;
39
40
virtual
VirtualObj
LoadModule
(
const
std::string& name) = 0;
41
42
const
LangID
lang_id
() {
return
lang_id_; }
43
44
protected
:
45
46
private
:
47
48
template
<
class
loader_t>
49
friend
class
InheritableLangWrapper
;
50
51
const
std::string file_extension_;
52
const
LangID
lang_id_;
53
54
LangWrapper
(
const
std::string&
file_extension
,
const
LangID
id
) :
55
file_extension_(file_extension),
56
lang_id_(id) {}
57
58
LangWrapper
& operator=(
const
LangWrapper
& rhs);
59
60
};
61
63
86
template
<
class
loader_t>
87
class
InheritableLangWrapper
:
public
LangWrapper
{
88
89
public
:
90
91
/*bool RegisterModule(const std::string& module_name, loader_t init_func) {
92
return RegisterModule(Module<loader_t>(module_name, init_func));
93
}*/
94
95
bool
RegisterModule
(
const
Module<loader_t>
& module) {
96
if
(module.
name
().empty())
97
return
false
;
98
// TODO: check if name is valid.
99
modules_
.push_back(module);
100
return
true
;
101
}
102
103
protected
:
104
105
std::vector< Module<loader_t> >
modules_
;
106
107
InheritableLangWrapper
(
const
std::string&
file_extension
,
const
LangID
id
) :
108
LangWrapper
(file_extension, id) {}
109
110
};
111
112
}
/* namespace script */
113
}
/* namespace ugdk */
114
115
#endif
/* UGDK_SCRIPT_LANGWRAPPER_H_ */
src
ugdk
script
langwrapper.h
Generated on Sat Oct 13 2012 02:25:11 for UGDK by
1.8.2