Commit | Line | Data |
---|---|---|
970ed795 EL |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Copyright (c) 2000-2014 Ericsson Telecom AB | |
3 | // All rights reserved. This program and the accompanying materials | |
4 | // are made available under the terms of the Eclipse Public License v1.0 | |
5 | // which accompanies this distribution, and is available at | |
6 | // http://www.eclipse.org/legal/epl-v10.html | |
7 | /////////////////////////////////////////////////////////////////////////////// | |
8 | #ifndef MODULE_LIST_HH | |
9 | #define MODULE_LIST_HH | |
10 | ||
11 | #include <stdio.h> | |
12 | #include "Types.h" | |
13 | ||
14 | class Text_Buf; | |
15 | class TTCN_Module; | |
16 | class Module_Param; | |
17 | class ModuleVersion; | |
18 | struct namespace_t; | |
19 | ||
20 | typedef void (*genericfunc_t)(void); | |
21 | ||
22 | class Module_List { | |
23 | static TTCN_Module *list_head, *list_tail; | |
24 | ||
25 | public: | |
26 | static void add_module(TTCN_Module *module_ptr); | |
27 | static void remove_module(TTCN_Module *module_ptr); | |
28 | static TTCN_Module *lookup_module(const char *module_name); | |
29 | static TTCN_Module *single_control_part(); | |
30 | ||
31 | static void pre_init_modules(); | |
32 | static void post_init_modules(); | |
33 | ||
34 | static void start_function(const char *module_name, | |
35 | const char *function_name, Text_Buf& function_arguments); | |
36 | ||
37 | static void initialize_component(const char *module_name, | |
38 | const char *component_type, boolean init_base_comps); | |
39 | ||
40 | static void set_param(Module_Param& param); | |
41 | static void log_param(); | |
42 | ||
43 | static void execute_control(const char *module_name); | |
44 | static void execute_testcase(const char *module_name, | |
45 | const char *testcase_name); | |
46 | static void execute_all_testcases(const char *module_name); | |
47 | ||
48 | static void print_version(); | |
49 | static void send_versions(); | |
50 | static void list_testcases(); | |
51 | static void push_version(Text_Buf& text_buf); | |
52 | ||
53 | static void encode_function(Text_Buf& text_buf, | |
54 | genericfunc_t function_address); | |
55 | static void decode_function(Text_Buf& text_buf, | |
56 | genericfunc_t *function_addr_ptr); | |
57 | static void log_function(genericfunc_t function_address); | |
58 | static void encode_altstep(Text_Buf& text_buf, | |
59 | genericfunc_t altstep_address); | |
60 | static void decode_altstep(Text_Buf& text_buf, | |
61 | genericfunc_t *altstep_addr_ptr); | |
62 | static void log_altstep(genericfunc_t altstep_address); | |
63 | static void encode_testcase(Text_Buf& text_buf, | |
64 | genericfunc_t testcase_address); | |
65 | static void decode_testcase(Text_Buf& text_buf, | |
66 | genericfunc_t *testcase_addr_ptr); | |
67 | static void log_testcase(genericfunc_t testcase_address); | |
68 | ||
69 | static genericfunc_t get_fat_null(); | |
70 | ||
71 | static genericfunc_t lookup_start_by_function_address( | |
72 | genericfunc_t function_address); | |
73 | static genericfunc_t lookup_standalone_address_by_altstep_address( | |
74 | genericfunc_t altstep_address); | |
75 | static genericfunc_t lookup_activate_address_by_altstep_address( | |
76 | genericfunc_t altstep_address); | |
77 | ||
78 | private: | |
79 | static boolean lookup_function_by_address(genericfunc_t function_address, | |
80 | const char*& module_name, const char*& function_name); | |
81 | static boolean lookup_altstep_by_address(genericfunc_t altstep_address, | |
82 | const char*& module_name, const char*& altstep_name); | |
83 | static boolean lookup_testcase_by_address(genericfunc_t testcase_address, | |
84 | const char*& module_name, const char*& testcase_name); | |
85 | }; | |
86 | ||
87 | class TTCN_Module { | |
88 | friend class Module_List; | |
89 | public: | |
90 | enum module_type_enum { TTCN3_MODULE, ASN1_MODULE, CPLUSPLUS_MODULE }; | |
91 | typedef void (*init_func_t)(); | |
92 | typedef boolean (*set_param_func_t)(Module_Param& param); | |
93 | typedef void (*log_param_func_t)(); | |
94 | typedef boolean (*initialize_component_func_t)(const char *component_type, | |
95 | boolean init_base_comps); | |
96 | typedef boolean (*start_func_t)(const char *function_name, | |
97 | Text_Buf& function_arguments); | |
98 | typedef void (*control_func_t)(); | |
99 | typedef verdicttype (*testcase_t)(boolean has_timer, double timer_value); | |
100 | ||
101 | private: | |
102 | TTCN_Module *list_prev, *list_next; | |
103 | module_type_enum module_type; | |
104 | const char *module_name; | |
105 | const char *compilation_date; | |
106 | const char *compilation_time; | |
107 | const unsigned char *md5_checksum; | |
108 | const char* product_number; | |
109 | unsigned int suffix; | |
110 | unsigned int release; | |
111 | unsigned int patch; | |
112 | unsigned int build; | |
113 | const char* extra; | |
114 | size_t num_namespaces; | |
115 | const namespace_t *xer_namespaces; | |
116 | // FIXME instead of each module having its own list of namespaces with gaps, | |
117 | // it may be better to have one global list in e.g. Module_list. | |
118 | // Trouble is, Module_list is not really a class: there is no instance of it | |
119 | // and it only has static members. | |
120 | init_func_t pre_init_func, post_init_func; | |
121 | boolean pre_init_called, post_init_called; | |
122 | set_param_func_t set_param_func; | |
123 | log_param_func_t log_param_func; | |
124 | initialize_component_func_t initialize_component_func; | |
125 | start_func_t start_func; | |
126 | control_func_t control_func; | |
127 | struct function_list_item; | |
128 | function_list_item *function_head, *function_tail; | |
129 | struct altstep_list_item; | |
130 | altstep_list_item *altstep_head, *altstep_tail; | |
131 | struct testcase_list_item; | |
132 | testcase_list_item *testcase_head, *testcase_tail; | |
133 | ||
134 | /// Copy constructor disabled | |
135 | TTCN_Module(const TTCN_Module&); | |
136 | /// Assignment disabled | |
137 | TTCN_Module& operator=(const TTCN_Module&); | |
138 | public: | |
139 | TTCN_Module(const char *par_module_name, | |
140 | const char *par_compilation_date, | |
141 | const char *par_compilation_time, | |
142 | const unsigned char *par_md5_checksum, | |
143 | init_func_t par_pre_init_func, | |
144 | const char* par_product_number, | |
145 | unsigned int par_suffix, | |
146 | unsigned int par_release, | |
147 | unsigned int par_patch, | |
148 | unsigned int par_build, | |
149 | const char* par_extra, | |
150 | size_t par_num_namespace, | |
151 | const namespace_t *par_namespaces, | |
152 | init_func_t par_post_init_func, | |
153 | set_param_func_t par_set_param_func, | |
154 | log_param_func_t par_log_param_func, | |
155 | initialize_component_func_t par_initialize_component_func, | |
156 | start_func_t par_start_func, | |
157 | control_func_t par_control_func); | |
158 | TTCN_Module(const char *par_module_name, | |
159 | const char *par_compilation_date, | |
160 | const char *par_compilation_time, | |
161 | const unsigned char *par_md5_checksum, | |
162 | init_func_t par_init_func); | |
163 | TTCN_Module(const char *par_module_name, | |
164 | const char *par_compilation_date, | |
165 | const char *par_compilation_time, | |
166 | init_func_t par_init_func = NULL); | |
167 | ~TTCN_Module(); | |
168 | const char *get_name() const { return module_name; } | |
169 | ||
170 | void pre_init_module(); | |
171 | void post_init_module(); | |
172 | ||
173 | void add_function(const char *function_name, genericfunc_t function_address, | |
174 | genericfunc_t start_address); | |
175 | void add_altstep(const char *altstep_name, genericfunc_t altstep_address, | |
176 | genericfunc_t activate_address, genericfunc_t standalone_address); | |
177 | void add_testcase_nonpard(const char *testcase_name, | |
178 | testcase_t testcase_function); | |
179 | void add_testcase_pard(const char *testcase_name, | |
180 | genericfunc_t testcase_address); | |
181 | ||
182 | void execute_testcase(const char *testcase_name); | |
183 | void execute_all_testcases(); | |
184 | ||
185 | const char *get_function_name_by_address(genericfunc_t function_address); | |
186 | genericfunc_t get_function_address_by_name(const char *function_name); | |
187 | genericfunc_t get_function_start_by_address(genericfunc_t function_address); | |
188 | const char *get_altstep_name_by_address(genericfunc_t altstep_address); | |
189 | genericfunc_t get_altstep_address_by_name(const char *altstep_name); | |
190 | boolean get_altstep_data_by_address(genericfunc_t altstep_address, | |
191 | genericfunc_t& standalone_address, genericfunc_t& activate_address); | |
192 | const char *get_testcase_name_by_address(genericfunc_t testcase_address); | |
193 | genericfunc_t get_testcase_address_by_name(const char *testcase_name); | |
194 | ||
195 | void print_version(); | |
196 | ModuleVersion* get_version() const; | |
197 | void list_testcases(); | |
198 | size_t get_num_ns() const { return num_namespaces; } | |
199 | const namespace_t *get_ns(size_t p_index) const; | |
200 | const namespace_t *get_controlns() const; | |
201 | }; | |
202 | ||
203 | #endif |