libamxo  4.3.4
Object Definition Language (ODL) parsing
test_valid.odl
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (c) 2020 SoftAtHome
4 **
5 ** Redistribution and use in source and binary forms, with or
6 ** without modification, are permitted provided that the following
7 ** conditions are met:
8 **
9 ** 1. Redistributions of source code must retain the above copyright
10 ** notice, this list of conditions and the following disclaimer.
11 **
12 ** 2. Redistributions in binary form must reproduce the above
13 ** copyright notice, this list of conditions and the following
14 ** disclaimer in the documentation and/or other materials provided
15 ** with the distribution.
16 **
17 ** Subject to the terms and conditions of this license, each
18 ** copyright holder and contributor hereby grants to those receiving
19 ** rights under this license a perpetual, worldwide, non-exclusive,
20 ** no-charge, royalty-free, irrevocable (except for failure to
21 ** satisfy the conditions of this license) patent license to make,
22 ** have made, use, offer to sell, sell, import, and otherwise
23 ** transfer this software, where such license applies only to those
24 ** patent claims, already acquired or hereafter acquired, licensable
25 ** by such copyright holder or contributor that are necessarily
26 ** infringed by:
27 **
28 ** (a) their Contribution(s) (the licensed copyrights of copyright
29 ** holders and non-copyrightable additions of contributors, in
30 ** source or binary form) alone; or
31 **
32 ** (b) combination of their Contribution(s) with the work of
33 ** authorship to which such Contribution(s) was added by such
34 ** copyright holder or contributor, if, at the time the Contribution
35 ** is added, such addition causes such combination to be necessarily
36 ** infringed. The patent license shall not apply to any other
37 ** combinations which include the Contribution.
38 **
39 ** Except as expressly stated above, no rights or licenses from any
40 ** copyright holder or contributor is granted under this license,
41 ** whether expressly, by implication, estoppel or otherwise.
42 **
43 ** DISCLAIMER
44 **
45 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
46 ** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
47 ** INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
48 ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
49 ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
50 ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
52 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
53 ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
54 ** AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
56 ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
57 ** POSSIBILITY OF SUCH DAMAGE.
58 **
59 ****************************************************************************/
61  test_option_number = 123;
62  test_option_string = "This is a text";
64  counter_name = "TestNumberOfEntries";
65  object_name = "TestSingeltonObjectAttr";
66  instance_name = "Name2";
67  function_name = "func16";
68  the_unique_param = "UniqueParam";
69 }
70 
71 import "test_plugin.so" as test_plugin;
72 
73 print "Hello";
74 
75 print "Resolve functions = ${odl-resolve}";
76 
77 %define {
78  entry-point test_plugin.test_entry_point;
79 
80  mib TestMib {
81  void mibfunc();
82 
83  string mibparam = "123";
84 
85  object MibObject;
86  }
87 
88  object TestObjectRoot {
89 
90  object TestObjectSingelton;
91  %protected %read-only %persistent %private object TestObjSingletonAttr;
92  object TestObjectTemplate[];
93  %protected %read-only %persistent %private object TestObjTemplateAttr[];
94 
95  object TestObjectParamTypes {
96  string Param1 {
97  default "choice1";
98  on action validate call check_enum [ "choiceA", "choice1", "choiceB" ];
99  }
100  int32 Param2;
101  int64 Param3 {
102  on action validate call check_range { min = -10, max = -1 };
103  default -5;
104  }
105  uint32 Param4;
106  uint64 Param5;
107  bool Param6;
108  double Param7;
109  ssv_string Param8;
110  csv_string Param9;
111  int8 Param10;
112  int16 Param11;
113  uint8 Param12;
114  uint16 Param13;
115  }
116 
117  object TestObjectFunctions {
118  void func1();
119  string func2();
120  int32 func3();
121  int64 func4();
122  uint32 func5();
123  uint64 func6();
124  bool func7();
125  double func8();
126  list func9();
127  htable func10();
128  variant func11();
129  void func12(string arg1,
130  int32 arg2,
131  int64 arg3,
132  uint32 arg4,
133  uint64 arg5,
134  bool arg6,
135  double arg7,
136  list arg8,
137  htable arg9,
138  variant arg10,
139  int8 arg11,
140  int16 arg12,
141  uint8 arg13,
142  uint16 arg14);
143  int8 func13();
144  int16 func14();
145  uint8 func15();
146  uint16 '${function_name}'();
147  }
148 
149  %protected %read-only %persistent object "${object_name}" {
150  %read-only %persistent %private %template %instance %volatile string Param1;
151  }
152 
153  object TestSingeltonParamAttr {
154  %protected %read-only %persistent %private %template %instance %volatile string Param1;
155  }
156  object TestTemplateParamAttr[] {
157  counted with "${counter_name}";
158  %protected %read-only %persistent %private %template %instance %volatile string Param1;
159  %template string Param2 {
160  on action validate call check_enum [ "value1", "value2", "value3" ];
161  default "value2";
162  }
163  %instance string Param3;
164  }
165 
166  object TestSingletonFuncAttr {
167  %protected %private %template %instance void TestFunc1();
168  void TestFunc2(%mandatory %in %out %strict int32 number);
169  }
170  object TestTemplateFuncAttr {
171  %private %template %instance void TestFunc1();
172  %template void TestFunc2();
173  %instance void TestFunc3();
174  void TestFunc4(%mandatory %in %out %strict int32 number);
175  }
176 
177  object TestObjectTemplateWithChild[] {
178  counted with TestObjectTemplateWithChildCounter;
179  object TemplateChildObject {
180  string Param1;
181  void func1();
182  }
183  }
184 
185  object TestObjectTemplateWithKeys[] {
186  %key string KeyPart1;
187  %mutable %key uint32 KeyPart2;
188  %key string KeyPart3;
189  %unique string '${the_unique_param}';
190 
191  string Param1;
192  bool Param2;
193  }
194 
195  %read-only object TestChangeAttr {
196  %private string Param1;
197  %private void Func1();
198  }
199 
200  object ExtendWithTestMib {
201  extend using mib TestMib;
202 
203  int32 TestParam {
204  on action read call test_dummy_action;
205  }
206  }
207 
208  object TestObjectEvent {
209  string Text;
210 
211  event 'MyEvent!';
212  }
213  }
214 }
215 
216 %populate {
217  object TestObjectRoot.TestObjectTemplateWithChild {
218  instance add(1,"Name1") {
219  object TemplateChildObject {
220  parameter Param1 = "Some Text";
221  }
222  }
223  instance add(2,"${instance_name}") {
224  extend using mib TestMib;
225  }
226  }
227 
228  object TestObjectRoot.TestTemplateParamAttr {
229  parameter Param2 = "value1";
230  parameter Param1 = "This is param 1";
231  instance add(99,"") {
232  parameter Param1 = "This is param 1 in instance";
233  parameter Param3 = "Hello World";
234  }
235  instance add(0, "");
236  }
237 
238  object TestObjectRoot.TestObjectTemplateWithKeys {
239  instance add(1,"",
240  KeyPart1 = "Key1A",
241  KeyPart2 = 100,
242  KeyPart3 = "Key1B") {
243  parameter Param1= "Some Text";
244  parameter Param2 = true;
245  parameter '${the_unique_param}' = "Key1";
246  }
247  instance add(0,"Test",
248  KeyPart1 = "Key2A",
249  KeyPart2 = 100,
250  KeyPart3 = "Key2B") {
251  parameter Param1= "Some Text";
252  parameter Param2 = true;
253  parameter '${the_unique_param}' = "Key2";
254  }
255  instance add(KeyPart1 = "Key3A",
256  KeyPart2 = 1,
257  KeyPart3 = "Key3B") {
258  parameter Param1= "Some Text";
259  parameter Param2 = true;
260  parameter '${the_unique_param}' = "Key3";
261  }
262  }
263 
264  !read-only %persistent object TestObjectRoot.TestChangeAttr {
265  !private %read-only parameter Param1;
266  }
267 
268  on event ".*" of ".*" call handle_event;
269  on event ".*" call handle_events
270  filter "object matches \"TestObjectRoot\.TestObjectTempl.*\"";
271 }
272 
273 %config {
274  define-behavior = {
275  existing-object = "update"
276  };
277 }
278 
279 %define {
280  object TestObjectRoot {
281  object TestObjectTemplateWithKeys {
282  object Test {
283  void testfunc(%in string arg);
284  string ExtraParameter = "TEST";
285  void get();
286  }
287  }
288  }
289 }
test_option_bool
Definition: test_valid.odl:63
test_option_string
Definition: test_valid.odl:62
config
Definition: test_valid.odl:60
the_unique_param
Definition: test_valid.odl:68
instance_name
Definition: test_valid.odl:66
object_name
Definition: test_valid.odl:65
function_name
Definition: test_valid.odl:67
counter_name
Definition: test_valid.odl:64
define
Definition: main.odl:1
static amxd_status_t test_dummy_action(UNUSED amxd_object_t *const object, UNUSED amxd_param_t *const param, UNUSED amxd_action_t reason, UNUSED const amxc_var_t *const args, UNUSED amxc_var_t *const retval, UNUSED void *priv)
amxd_status_t TestFunc4(amxd_object_t *object, amxd_function_t *func, amxc_var_t *args, amxc_var_t *ret)
Definition: test_plugin.c:182