3 #include "StackWalker.h"
6 #include "TypeParser.h"
7 #include "ValueParser.h"
9 #include "DataBoardRepository.h"
10 #include "DataValueRepository.h"
12 #include "RecordType.h"
13 #include "Component.h"
15 #include "RecordValue.h"
16 #include "StringValue.h"
17 #include "IntegerValue.h"
18 #include "DoubleValue.h"
19 #include "ArrayValue.h"
22 #include "IntegerType.h"
23 #include "StringType.h"
27 #include "NumberType.h"
35 std::cout << "Output of dbt & dbv files:" << std::endl;
37 Databoard::Type::DataBoardRepository* typeRepo = Databoard::Type::parse("input11.dbt");
41 std::cerr << "type repository not found" << std::endl;
46 Databoard::Type::DataType* type = typeRepo->getDataBoard("PBEparticle");
50 std::cerr << "type not found" << std::endl;
55 Databoard::Value::Value* value = Databoard::Value::parse("input12.dbv", type);
59 std::cerr << "value not found" << std::endl;
64 //Databoard::Type::RecordType* r = ((Databoard::Type::RecordType*)type);
66 //std::cout << r->getComponentIndex("FractalIndex") << std::endl;
67 //std::cout << r->getComponentIndex("Bondforce") << std::endl;
68 //std::cout << r->getComponentIndex("Density") << std::endl;
69 //std::cout << r->getComponentIndex("RefractiveIndex") << std::endl;
70 //std::cout << r->getComponentIndex("UVabsorption") << std::endl;
71 //std::cout << r->getComponentIndex("SurfacePotential") << std::endl;
72 //std::cout << r->getComponentIndex("SurfaceCharge") << std::endl;
73 //std::cout << r->getComponentIndex("RPermittivity") << std::endl;
74 //std::cout << r->getComponentIndex("AvgRadius") << std::endl;
76 //Databoard::Value::RecordValue* t = ((Databoard::Value::RecordValue*)value);
78 //Databoard::Value::DoubleValue* f0 = (Databoard::Value::DoubleValue*)t->getField(0);
79 //Databoard::Value::DoubleValue* f1 = (Databoard::Value::DoubleValue*)t->getField(1);
80 //Databoard::Value::DoubleValue* f2 = (Databoard::Value::DoubleValue*)t->getField(2);
81 //Databoard::Value::DoubleValue* f3 = (Databoard::Value::DoubleValue*)t->getField(3);
82 //Databoard::Value::RecordValue* f4 = (Databoard::Value::RecordValue*)t->getField(4);
83 //Databoard::Value::DoubleValue* f5 = (Databoard::Value::DoubleValue*)t->getField(5);
84 //Databoard::Value::DoubleValue* f6 = (Databoard::Value::DoubleValue*)t->getField(6);
85 //Databoard::Value::DoubleValue* f7 = (Databoard::Value::DoubleValue*)t->getField(7);
86 //Databoard::Value::DoubleValue* f8 = (Databoard::Value::DoubleValue*)t->getField(8);
88 //std::cout << f0->getValue() << std::endl;
89 //std::cout << f1->getValue() << std::endl;
90 //std::cout << f2->getValue() << std::endl;
91 //std::cout << f3->getValue() << std::endl;
93 //std::cout << ((Databoard::Value::DoubleValue*)f4->getField(0))->getValue() << std::endl;
94 //std::cout << ((Databoard::Value::DoubleValue*)f4->getField(1))->getValue() << std::endl;
96 //std::cout << f5->getValue() << std::endl;
97 //std::cout << f6->getValue() << std::endl;
98 //std::cout << f7->getValue() << std::endl;
99 //std::cout << f8->getValue() << std::endl;
101 std::cout << type->writeOut() << std::endl;
102 std::cout << value->writeOut() << std::endl;
107 std::cout << "..." << std::endl;
112 std::cout << "Output of dbt & dbd(s) files:" << std::endl;
114 Databoard::Type::DataBoardRepository* typeRepo = Databoard::Type::parse("input23.dbt");
118 std::cerr << "type repository not found" << std::endl;
123 Databoard::Value::DataValueRepository* valueRepo = NULL;
124 Databoard::Value::parse("input24_1.dbd", valueRepo, typeRepo);
125 Databoard::Value::parse("input24_2.dbd", valueRepo, typeRepo);
127 const Databoard::Value::strDataValueDefinition* v1 = valueRepo->getDataValue("a");
128 const Databoard::Value::strDataValueDefinition* v2 = valueRepo->getDataValue("b");
130 std::cout << "... printing types:" << std::endl;
132 for(int i = 0; i < typeRepo->count(); ++i)
134 std::cout << "#" << i << ":" << std::endl;
136 std::cout << typeRepo->getDataBoard(i).writeOut() << std::endl << std::endl;
141 std::cout << "... printing value definition:" << std::endl;
143 std::cout << v1->writeOut() << std::endl;
145 std::string v = v1->value->isValid();
149 std::cout << "type is invalid: " << v << std::endl;
153 std::cout << "type is valid" << std::endl;
159 std::cout << "... printing value definition:" << std::endl;
161 std::cout << v2->writeOut() << std::endl;
163 std::string v = v2->value->isValid();
167 std::cout << "type is invalid: " << v << std::endl;
171 std::cout << "type is valid" << std::endl;
176 Databoard::Value::free(valueRepo);
177 Databoard::Type::free(typeRepo);
179 std::cout << "..." << std::endl;
185 std::cout << "Output of dbt file:" << std::endl;
187 Databoard::Type::DataBoardRepository* typeRepo = Databoard::Type::parse("input17.dbt");
189 Databoard::Type::DataType* type = typeRepo->getDataBoard("Complex");
193 std::cerr << "type not found" << std::endl;
198 std::cout << type->writeOut() << std::endl;
200 Databoard::Value::MapValue* mapValue = new Databoard::Value::MapValue(type);
202 Databoard::Type::IntegerType* integerType = new Databoard::Type::IntegerType();
203 Databoard::Type::StringType* stringType = new Databoard::Type::StringType();
205 Databoard::Value::IntegerValue* k0 = new Databoard::Value::IntegerValue(integerType);
206 Databoard::Value::IntegerValue* k1 = new Databoard::Value::IntegerValue(integerType);
207 Databoard::Value::IntegerValue* k2 = new Databoard::Value::IntegerValue(integerType);
208 Databoard::Value::IntegerValue* k3 = new Databoard::Value::IntegerValue(integerType);
210 Databoard::Value::StringValue* v0 = new Databoard::Value::StringValue(stringType);
211 Databoard::Value::StringValue* v1 = new Databoard::Value::StringValue(stringType);
212 Databoard::Value::StringValue* v2 = new Databoard::Value::StringValue(stringType);
213 Databoard::Value::StringValue* v3 = new Databoard::Value::StringValue(stringType);
220 v0->setValue("asd0");
221 v1->setValue("asd1");
222 v2->setValue("asd2");
223 v3->setValue("asd3");
225 std::cout << "mappi:" << std::endl << mapValue->writeOut() << std::endl;
226 mapValue->put(k0, v0);
228 std::cout << "mappi:" << std::endl << mapValue->writeOut() << std::endl;
229 mapValue->put(k1, v1);
231 std::cout << "mappi:" << std::endl << mapValue->writeOut() << std::endl;
232 mapValue->put(k2, v2);
234 std::cout << "mappi:" << std::endl << mapValue->writeOut() << std::endl;
235 mapValue->put(k3, v3);
237 mapValue->removeRange(k0, k1);
239 //Databoard::Value::Value* old = mapValue->remove(k0);
248 Databoard::Type::free(typeRepo);
253 std::cout << "Output of dbt & dbv files:" << std::endl;
255 Databoard::Type::DataBoardRepository* typeRepo = Databoard::Type::parse("input25.dbt");
259 std::cerr << "type repository not found" << std::endl;
264 Databoard::Type::DataType* type = typeRepo->getDataBoard("AggreDist");
268 std::cerr << "type not found" << std::endl;
273 Databoard::Value::DataValueRepository* valueRepo = NULL;
274 Databoard::Value::parse("input26_3.dbd", valueRepo, typeRepo);
276 Databoard::Value::Value* value1 = Databoard::Value::parse("input26_1.dbv", type);
280 std::cerr << "value not found" << std::endl;
285 Databoard::Value::Value* value2 = Databoard::Value::parse("input26_2.dbv", type);
289 std::cerr << "value not found" << std::endl;
296 std::cout << "... printing value definition:" << std::endl;
298 std::cout << value1->writeOut() << std::endl;
300 std::string v = value1->isValid();
304 std::cout << "type is invalid: " << v << std::endl;
308 std::cout << "type is valid" << std::endl;
316 std::cout << "... printing value definition:" << std::endl;
318 std::cout << value2->writeOut() << std::endl;
320 std::string v = value2->isValid();
324 std::cout << "type is invalid: " << v << std::endl;
328 std::cout << "type is valid" << std::endl;
337 std::cout << "..." << std::endl;
342 std::cout << "Output of dbt & dbv files:" << std::endl;
344 Databoard::Type::DataBoardRepository* typeRepo = Databoard::Type::parse("input27.dbt");
348 std::cerr << "type repository not found" << std::endl;
353 Databoard::Type::DataType* type = typeRepo->getDataBoard("Complex");
357 std::cerr << "type not found" << std::endl;
362 Databoard::Value::Value* value = Databoard::Value::parse("input28.dbv", type);
366 std::cerr << "value not found" << std::endl;
371 std::cout << type->writeOut() << std::endl;
372 std::cout << value->writeOut() << std::endl;
377 std::cout << "..." << std::endl;
382 std::cout << "Output of dbt & dbv files:" << std::endl;
384 Databoard::Type::DataBoardRepository* typeRepo = Databoard::Type::parse("input29.dbt");
388 std::cerr << "type repository not found" << std::endl;
393 Databoard::Type::DataType* type = typeRepo->getDataBoard("T");
397 std::cerr << "type not found" << std::endl;
402 Databoard::Value::Value* value1 = Databoard::Value::parse("input30.dbv", type);
406 std::cerr << "value not found" << std::endl;
411 Databoard::Value::RecordValue* recordValue = dynamic_cast<Databoard::Value::RecordValue*>(value1);
413 if(recordValue != NULL)
415 for(int i = 0; i < recordValue->count(); ++i)
417 Databoard::Value::Value* value = recordValue->getField(i);
419 Databoard::Value::ArrayValue* arrayValue = dynamic_cast<Databoard::Value::ArrayValue*>(value);
421 if(arrayValue != NULL)
424 //for(int j = 0; j < arrayValue->count(); ++j)
426 // Databoard::Value::Value* value = arrayValue->get(j);
428 // std::cout << value->writeOut() << std::endl;
432 std::vector<Databoard::Value::Value*> valueVector = arrayValue->getAll();
434 std::cout << "Row count: " << (int)valueVector.size() << std::endl;
436 for(int j = 0; j < (int)valueVector.size(); ++j)
438 Databoard::Value::RecordValue* recordValue = (Databoard::Value::RecordValue*)valueVector.at(j);
440 std::cout << "Element count: " << recordValue->count() << std::endl;
442 for(int k = 0; k < recordValue->count(); ++k)
444 Databoard::Value::DoubleValue* doubleValue = (Databoard::Value::DoubleValue*)recordValue->getField(k);
446 std::cout << doubleValue->getValue() << std::endl;
458 std::cout << "..." << std::endl;