Line data Source code
1 : #define IOW_DISABLE_LOG
2 : #include <iow/logger.hpp>
3 : #include <wfc/domain_object.hpp>
4 : #include <wfc/module/instance.hpp>
5 : #include <wfc/module/singleton.hpp>
6 : #include <wfc/module/multiton.hpp>
7 : #include <fas/utility/ignore_args.hpp>
8 :
9 4 : struct itest:
10 : public wfc::iinterface
11 : {
12 4 : ~itest(){}
13 : };
14 :
15 16 : struct options
16 : {
17 : int test = 33;
18 : };
19 :
20 : struct options_json
21 : {
22 7 : JSON_NAME(test)
23 : typedef wfc::json::object<
24 : options,
25 : fas::type_list_n<
26 : wfc::json::member<n_test, options, int, &options::test>
27 : >::type
28 : > type;
29 :
30 : typedef typename type::serializer serializer;
31 : typedef typename type::member_list member_list;
32 : typedef typename type::target target;
33 : };
34 :
35 8 : class test:
36 : public ::wfc::domain_object<itest, options>
37 : {
38 :
39 : };
40 :
41 6 : JSON_NAME2(name_test, "test")
42 :
43 2 : class test_singleton
44 : : public ::wfc::singleton< name_test, ::wfc::instance<test>, options_json >
45 : {};
46 :
47 :
48 2 : class test_multiton
49 : : public ::wfc::multiton< name_test, ::wfc::instance<test>, options_json >
50 : {};
51 :
52 : template<typename T>
53 2 : int test_gen()
54 : {
55 2 : T t;
56 2 : t.create(nullptr);
57 2 : std::cout << "[" << t.interface_name() << "]" << std::endl;
58 4 : std::string genstr = t.generate("");
59 2 : std::cout << genstr << std::endl;
60 2 : t.configure(genstr, nullptr);
61 2 : if (t.name()!="test")
62 0 : return 1;
63 :
64 4 : return 0;
65 : }
66 :
67 1 : int main()
68 : {
69 1 : options opt;
70 1 : opt.test=0;
71 1 : fas::ignore_arg(opt);
72 1 : int res = test_gen<test_singleton>();
73 1 : res += test_gen<test_multiton>();
74 1 : return res;
75 3 : }
|