45int test_publisher(std::shared_ptr<adc::publisher_api> pi, std::shared_ptr< adc::builder_api> b, std::map<std::string, std::string>& pconfig ) {
46 std::cout <<
"------------------- begin --------------------" << std::endl;
49 err = pi->config(pconfig);
51 std::cout <<
"config failed " <<
52 std::strerror(err) << std::endl;
56 err = pi->initialize();
58 std::cout <<
"initialize failed " <<
59 std::strerror(err) << std::endl;
65 std::cout <<
"publish 1 failed " <<
66 std::strerror(err) << std::endl;
73 std::cout <<
"publish 2 failed " <<
74 std::strerror(err) << std::endl;
81 std::cout <<
"publish 3 failed " <<
82 std::strerror(err) << std::endl;
87 std::cout <<
"------------------- end --------------------" << std::endl;
93 std::shared_ptr< adc::builder_api > app_data = f.
get_builder();
94#if ADC_BOOST_JSON_PUBLIC
95 boost::json::object jo = {{
"a",
"b"},{
"C",
"d"},{
"n",1}};
97 app_data->add(
"bool0",
false);
98 app_data->add(
"bool1",
true);
99 app_data->add(
"char1",
'A');
100 app_data->add(
"c16", u
'¢');
101 app_data->add(
"c32", U
'猫');
102 const std::string ccppstr(
"ccppstr");
103 app_data->add(
"ccppstr", ccppstr);
104 std::string cppstr(
"cppstr");
105 app_data->add(
"cppstr", cppstr);
107 const char *cstr =
"cstr_nul";
108 app_data->add(
"cstr1", cstr);
110 app_data->add_json_string(
"jstr1", std::string (
"{\"a\":\"b\", \"c\":[1,2, 3]}"));
111#if ADC_BOOST_JSON_PUBLIC
112 app_data->add(
"jsonobj", jo);
114 uint8_t u8 = std::numeric_limits<uint8_t>::max();
115 uint16_t u16 = std::numeric_limits<uint16_t>::max();
116 uint32_t u32 = std::numeric_limits<uint32_t>::max();
117 uint64_t u64 = std::numeric_limits<uint64_t>::max();
118 app_data->add(
"u8", u8);
119 app_data->add(
"u16", u16);
120 app_data->add(
"u32", u32);
121 app_data->add(
"u64", u64);
122 int8_t i8 = std::numeric_limits<int8_t>::max();
123 int16_t i16 = std::numeric_limits<int16_t>::max();
124 int32_t i32 = std::numeric_limits<int32_t>::max();
125 int64_t i64 = std::numeric_limits<int64_t>::max();
126 app_data->add(
"i8", i8);
127 app_data->add(
"i16", i16);
128 app_data->add(
"i32", i32);
129 app_data->add(
"i64", i64);
130 app_data->add(
"flt", std::numeric_limits<float>::max());
131 app_data->add(
"dbl", std::numeric_limits<double>::max() );
132 app_data->add(
"fcplx", std::complex<float>(
133 std::numeric_limits<float>::max(),std::numeric_limits<float>::max()));
134 app_data->add(
"dcplx", std::complex<double>(
135 std::numeric_limits<double>::max(),std::numeric_limits<double>::max()));
136 const char *cstrings[] = {
"a",
"B",
"c2"};
143 for (
int i = 0; i < 4; i++) {
144 vcstrings[i] =
new char[2];
145 snprintf(vcstrings[i], 2,
"%d", i);
147 ua64[i] = std::numeric_limits<uint64_t>::max() - i;
152 std::string cppstrings[] = {
"ap",
"Bp",
"c2p"};
153 app_data->add_array(
"nulembed",
"a\0b", 3);
154 app_data->add_array(
"cstrs", cstrings, 3);
155 app_data->add_array(
"cppstrs", cppstrings, 3);
156 app_data->add_array(
"vcstrs", vcstrings, 4);
157 for (
int i = 0; i < 4; i++) {
158 delete [] vcstrings[i];
160 app_data->add_array(
"ia", ia, 4);
161 app_data->add_array(
"ua", ua, 4);
162 app_data->add_array(
"ua64", ua64, 4);
163 app_data->add_array(
"fa", fa, 4);
164 app_data->add_array(
"da", da, 4);
166 b->add_header_section(
"cxx_demo_1");
170 b->add_app_data_section(app_data);
172 b->add_memory_usage_section();
174 std::shared_ptr< adc::builder_api > code_details = f.
get_builder();
177 std::shared_ptr< adc::builder_api > version = f.
get_builder();
178 version->add(
"version",
"1.1.2");
179 const char* tags[] = {
"boca_raton",
"saronida_2"};
180 version->add_array(
"tags", tags ,2);
181 version->add(
"mesh_version",
"5.0.0");
183 b->add_code_section(
"repartitioner", version, code_details);
185 std::shared_ptr< adc::builder_api > build_details = f.
get_builder();
186 b->add_code_configuration_section(build_details);
188 std::shared_ptr< adc::builder_api > model_data = f.
get_builder();
189 model_data->add(
"nx", 3);
190 model_data->add(
"ny", 10);
191 model_data->add(
"step", 0);
192 b->add_model_data_section(model_data);
194 std::shared_ptr< adc::builder_api > status_details = f.
get_builder();
195 status_details->add(
"tmax", 15000.25);
196 status_details->add(
"tmax_loc", 10325);
197 status_details->add(
"step", 234);
198 b->add_exit_data_section(1,
"we didn't succeed due to high temperatures", status_details);
201 std::string ss = b->serialize();
202 std::cout <<
"-------------------------------" << std::endl;
203 std::cout << ss << std::endl;
204 std::cout <<
"-------------------------------" << std::endl;