41int test_publisher(std::shared_ptr<adc::publisher_api> pi, std::shared_ptr< adc::builder_api> b, std::map<std::string, std::string>& pconfig ) {
42 std::cout <<
"------------------- begin --------------------" << std::endl;
45 err = pi->config(pconfig);
47 std::cout <<
"config failed " <<
48 std::strerror(err) << std::endl;
52 err = pi->initialize();
54 std::cout <<
"initialize failed " <<
55 std::strerror(err) << std::endl;
61 std::cout <<
"publish 1 failed " <<
62 std::strerror(err) << std::endl;
69 std::cout <<
"publish 2 failed " <<
70 std::strerror(err) << std::endl;
77 std::cout <<
"publish 3 failed " <<
78 std::strerror(err) << std::endl;
83 std::cout <<
"------------------- end --------------------" << std::endl;
89 std::shared_ptr< adc::builder_api > app_data = f.
get_builder();
90#if ADC_BOOST_JSON_PUBLIC
91 boost::json::object jo = {{
"a",
"b"},{
"C",
"d"},{
"n",1}};
93 app_data->add(
"bool0",
false);
94 app_data->add(
"bool1",
true);
95 app_data->add(
"char1",
'A');
96 app_data->add(
"c16", u
'¢');
97 app_data->add(
"c32", U
'猫');
98 const std::string ccppstr(
"ccppstr");
99 app_data->add(
"ccppstr", ccppstr);
100 std::string cppstr(
"cppstr");
101 app_data->add(
"cppstr", cppstr);
103 const char *cstr =
"cstr_nul";
104 app_data->add(
"cstr1", cstr);
106 app_data->add_json_string(
"jstr1", std::string (
"{\"a\":\"b\", \"c\":[1,2, 3]}"));
107#if ADC_BOOST_JSON_PUBLIC
108 app_data->add(
"jsonobj", jo);
110 uint8_t u8 = std::numeric_limits<uint8_t>::max();
111 uint16_t u16 = std::numeric_limits<uint16_t>::max();
112 uint32_t u32 = std::numeric_limits<uint32_t>::max();
113 uint64_t u64 = std::numeric_limits<uint64_t>::max();
114 app_data->add(
"u8", u8);
115 app_data->add(
"u16", u16);
116 app_data->add(
"u32", u32);
117 app_data->add(
"u64", u64);
118 int8_t i8 = std::numeric_limits<int8_t>::max();
119 int16_t i16 = std::numeric_limits<int16_t>::max();
120 int32_t i32 = std::numeric_limits<int32_t>::max();
121 int64_t i64 = std::numeric_limits<int64_t>::max();
122 app_data->add(
"i8", i8);
123 app_data->add(
"i16", i16);
124 app_data->add(
"i32", i32);
125 app_data->add(
"i64", i64);
126 app_data->add(
"flt", std::numeric_limits<float>::max());
127 app_data->add(
"dbl", std::numeric_limits<double>::max() );
128 app_data->add(
"fcplx", std::complex<float>(
129 std::numeric_limits<float>::max(),std::numeric_limits<float>::max()));
130 app_data->add(
"dcplx", std::complex<double>(
131 std::numeric_limits<double>::max(),std::numeric_limits<double>::max()));
132 const char *cstrings[] = {
"a",
"B",
"c2"};
139 for (
int i = 0; i < 4; i++) {
140 vcstrings[i] =
new char[2];
141 snprintf(vcstrings[i], 2,
"%d", i);
143 ua64[i] = std::numeric_limits<uint64_t>::max() - i;
148 std::string cppstrings[] = {
"ap",
"Bp",
"c2p"};
149 app_data->add_array(
"nulembed",
"a\0b", 3);
150 app_data->add_array(
"cstrs", cstrings, 3);
151 app_data->add_array(
"cppstrs", cppstrings, 3);
152 app_data->add_array(
"vcstrs", vcstrings, 4);
153 for (
int i = 0; i < 4; i++) {
154 delete [] vcstrings[i];
156 app_data->add_array(
"ia", ia, 4);
157 app_data->add_array(
"ua", ua, 4);
158 app_data->add_array(
"ua64", ua64, 4);
159 app_data->add_array(
"fa", fa, 4);
160 app_data->add_array(
"da", da, 4);
162 b->add_header_section(
"cxx_demo_1");
166 b->add_app_data_section(app_data);
168 b->add_memory_usage_section();
170 std::shared_ptr< adc::builder_api > code_details = f.
get_builder();
173 std::shared_ptr< adc::builder_api > version = f.
get_builder();
174 version->add(
"version",
"1.1.2");
175 const char* tags[] = {
"boca_raton",
"saronida_2"};
176 version->add_array(
"tags", tags ,2);
177 version->add(
"mesh_version",
"5.0.0");
179 b->add_code_section(
"repartitioner", version, code_details);
181 std::shared_ptr< adc::builder_api > build_details = f.
get_builder();
182 b->add_code_configuration_section(build_details);
184 std::shared_ptr< adc::builder_api > model_data = f.
get_builder();
185 model_data->add(
"nx", 3);
186 model_data->add(
"ny", 10);
187 model_data->add(
"step", 0);
188 b->add_model_data_section(model_data);
190 std::shared_ptr< adc::builder_api > status_details = f.
get_builder();
191 status_details->add(
"tmax", 15000.25);
192 status_details->add(
"tmax_loc", 10325);
193 status_details->add(
"step", 234);
194 b->add_exit_data_section(1,
"we didn't succeed due to high temperatures", status_details);
197 std::string ss = b->serialize();
198 std::cout <<
"-------------------------------" << std::endl;
199 std::cout << ss << std::endl;
200 std::cout <<
"-------------------------------" << std::endl;