comparison Applications/Samples/StoneSampleCommands_generated.hpp @ 535:79bb0a02d1cc bgo-commands-codegen

- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers) - Last fixes to new style command handling (removed useless commands and switch command handling in simple samples to use XxxxSerializedMessageXxxx instead of XxxxCommandXxxx - Fixed hardcoded input instance in SingleFrameEditorApplication
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 19 Mar 2019 09:13:57 +0100
parents b1377625e4ba
children 4eccf698e52f
comparison
equal deleted inserted replaced
534:7016c35d163c 535:79bb0a02d1cc
1 /* 1 /*
2 1 2 3 4 5 6 7 2 1 2 3 4 5 6 7
3 12345678901234567890123456789012345678901234567890123456789012345678901234567890 3 12345678901234567890123456789012345678901234567890123456789012345678901234567890
4 4
5 Generated on 2019-03-15 10:00:48.763392 by stonegentool 5 Generated on 2019-03-18 12:07:42.696093 by stonegentool
6 6
7 */ 7 */
8 #pragma once 8 #pragma once
9 9
10 #include <exception> 10 #include <exception>
84 // the following is better than 84 // the following is better than
85 Json::Value result(value.data(),value.data()+value.size()); 85 Json::Value result(value.data(),value.data()+value.size());
86 return result; 86 return result;
87 } 87 }
88 88
89 inline std::string MakeIndent(int indent) 89 inline std::string MakeIndent(size_t indent)
90 { 90 {
91 char* txt = reinterpret_cast<char*>(malloc(indent+1)); // NO EXCEPTION BELOW!!!!!!!!!!!! 91 char* txt = reinterpret_cast<char*>(malloc(indent+1)); // NO EXCEPTION BELOW!!!!!!!!!!!!
92 for(size_t i = 0; i < indent; ++i) 92 for(size_t i = 0; i < indent; ++i)
93 txt[i] = ' '; 93 txt[i] = ' ';
94 txt[indent] = 0; 94 txt[indent] = 0;
97 return retVal; 97 return retVal;
98 } 98 }
99 99
100 // generic dumper 100 // generic dumper
101 template<typename T> 101 template<typename T>
102 std::ostream& StoneDumpValue(std::ostream& out, const T& value, int indent) 102 std::ostream& StoneDumpValue(std::ostream& out, const T& value, size_t indent)
103 { 103 {
104 out << MakeIndent(indent) << value; 104 out << MakeIndent(indent) << value;
105 return out; 105 return out;
106 } 106 }
107 107
108 // string dumper 108 // string dumper
109 inline std::ostream& StoneDumpValue(std::ostream& out, const std::string& value, int indent) 109 inline std::ostream& StoneDumpValue(std::ostream& out, const std::string& value, size_t indent)
110 { 110 {
111 out << MakeIndent(indent) << "\"" << value << "\""; 111 out << MakeIndent(indent) << "\"" << value << "\"";
112 return out; 112 return out;
113 } 113 }
114 114
146 } 146 }
147 return result; 147 return result;
148 } 148 }
149 149
150 template<typename T> 150 template<typename T>
151 std::ostream& StoneDumpValue(std::ostream& out, const std::map<std::string,T>& value, int indent) 151 std::ostream& StoneDumpValue(std::ostream& out, const std::map<std::string,T>& value, size_t indent)
152 { 152 {
153 out << MakeIndent(indent) << "{\n"; 153 out << MakeIndent(indent) << "{\n";
154 for (typename std::map<std::string, T>::const_iterator it = value.cbegin(); 154 for (typename std::map<std::string, T>::const_iterator it = value.cbegin();
155 it != value.cend(); ++it) 155 it != value.cend(); ++it)
156 { 156 {
186 } 186 }
187 return result; 187 return result;
188 } 188 }
189 189
190 template<typename T> 190 template<typename T>
191 std::ostream& StoneDumpValue(std::ostream& out, const std::vector<T>& value, int indent) 191 std::ostream& StoneDumpValue(std::ostream& out, const std::vector<T>& value, size_t indent)
192 { 192 {
193 out << MakeIndent(indent) << "[\n"; 193 out << MakeIndent(indent) << "[\n";
194 for (size_t i = 0; i < value.size(); ++i) 194 for (size_t i = 0; i < value.size(); ++i)
195 { 195 {
196 StoneDumpValue(out, value[i], indent+2); 196 StoneDumpValue(out, value[i], indent+2);
370 { 370 {
371 std::string strValue = ToString(value); 371 std::string strValue = ToString(value);
372 return Json::Value(strValue); 372 return Json::Value(strValue);
373 } 373 }
374 374
375 inline std::ostream& StoneDumpValue(std::ostream& out, const Tool& value, int indent = 0) 375 inline std::ostream& StoneDumpValue(std::ostream& out, const Tool& value, size_t indent = 0)
376 { 376 {
377 if( value == Tool_LineMeasure) 377 if( value == Tool_LineMeasure)
378 { 378 {
379 out << MakeIndent(indent) << "LineMeasure" << std::endl; 379 out << MakeIndent(indent) << "LineMeasure" << std::endl;
380 } 380 }
483 { 483 {
484 std::string strValue = ToString(value); 484 std::string strValue = ToString(value);
485 return Json::Value(strValue); 485 return Json::Value(strValue);
486 } 486 }
487 487
488 inline std::ostream& StoneDumpValue(std::ostream& out, const ActionType& value, int indent = 0) 488 inline std::ostream& StoneDumpValue(std::ostream& out, const ActionType& value, size_t indent = 0)
489 { 489 {
490 if( value == ActionType_UndoCrop) 490 if( value == ActionType_UndoCrop)
491 { 491 {
492 out << MakeIndent(indent) << "UndoCrop" << std::endl; 492 out << MakeIndent(indent) << "UndoCrop" << std::endl;
493 } 493 }
529 result["tool"] = _StoneSerializeValue(value.tool); 529 result["tool"] = _StoneSerializeValue(value.tool);
530 530
531 return result; 531 return result;
532 } 532 }
533 533
534 inline std::ostream& StoneDumpValue(std::ostream& out, const SelectTool& value, int indent = 0) 534 inline std::ostream& StoneDumpValue(std::ostream& out, const SelectTool& value, size_t indent = 0)
535 { 535 {
536 out << MakeIndent(indent) << "{\n"; 536 out << MakeIndent(indent) << "{\n";
537 out << MakeIndent(indent) << "tool:\n"; 537 out << MakeIndent(indent) << "tool:\n";
538 StoneDumpValue(out, value.tool,indent+2); 538 StoneDumpValue(out, value.tool,indent+2);
539 out << "\n"; 539 out << "\n";
592 result["type"] = _StoneSerializeValue(value.type); 592 result["type"] = _StoneSerializeValue(value.type);
593 593
594 return result; 594 return result;
595 } 595 }
596 596
597 inline std::ostream& StoneDumpValue(std::ostream& out, const Action& value, int indent = 0) 597 inline std::ostream& StoneDumpValue(std::ostream& out, const Action& value, size_t indent = 0)
598 { 598 {
599 out << MakeIndent(indent) << "{\n"; 599 out << MakeIndent(indent) << "{\n";
600 out << MakeIndent(indent) << "type:\n"; 600 out << MakeIndent(indent) << "type:\n";
601 StoneDumpValue(out, value.type,indent+2); 601 StoneDumpValue(out, value.type,indent+2);
602 out << "\n"; 602 out << "\n";
636 636
637 class IHandler 637 class IHandler
638 { 638 {
639 public: 639 public:
640 virtual bool Handle(const SelectTool& value) = 0; 640 virtual bool Handle(const SelectTool& value) = 0;
641 virtual bool Handle(const Action& value) = 0;
641 }; 642 };
642 643
643 /** Service function for StoneDispatchToHandler */ 644 /** Service function for StoneDispatchToHandler */
644 inline bool StoneDispatchJsonToHandler( 645 inline bool StoneDispatchJsonToHandler(
645 const Json::Value& jsonValue, IHandler* handler) 646 const Json::Value& jsonValue, IHandler* handler)
652 throw std::runtime_error("Caught empty type while dispatching"); 653 throw std::runtime_error("Caught empty type while dispatching");
653 } 654 }
654 else if (type == "StoneSampleCommands.SelectTool") 655 else if (type == "StoneSampleCommands.SelectTool")
655 { 656 {
656 SelectTool value; 657 SelectTool value;
658 _StoneDeserializeValue(value, jsonValue["value"]);
659 return handler->Handle(value);
660 }
661 else if (type == "StoneSampleCommands.Action")
662 {
663 Action value;
657 _StoneDeserializeValue(value, jsonValue["value"]); 664 _StoneDeserializeValue(value, jsonValue["value"]);
658 return handler->Handle(value); 665 return handler->Handle(value);
659 } 666 }
660 else 667 else
661 { 668 {