23 #include <boost/foreach.hpp> 25 #include "goby/moos/moos_string.h" 26 #include "goby/util/as.h" 29 #include "message_algorithms.h" 30 #include "message_val.h" 31 #include "message_var.h" 33 goby::transitional::DCCLMessageVar::DCCLMessageVar()
34 : array_length_(1), is_key_frame_(true), sequence_number_(-1), source_set_(false),
35 ap_(DCCLAlgorithmPerformer::getInstance())
39 void goby::transitional::DCCLMessageVar::initialize(
const DCCLMessage& msg)
43 source_var_ = msg.trigger_var();
45 BOOST_FOREACH (
const std::string& alg, algorithms_)
46 ap_->check_algorithm(alg, msg);
48 initialize_specific();
51 void goby::transitional::DCCLMessageVar::set_defaults(
54 vals[name_].resize(array_length_);
56 std::vector<DCCLMessageVal>& vm = vals[name_];
58 for (std::vector<DCCLMessageVal>::size_type i = 0, n = vm.size(); i < n; ++i)
59 set_defaults_specific(vm[i], modem_id,
id);
62 void goby::transitional::DCCLMessageVar::write_schema_to_dccl2(std::ofstream* proto_file,
65 sequence_number_ = sequence_number;
69 if (array_length_ == 1)
70 *proto_file <<
"optional ";
72 *proto_file <<
"repeated ";
74 std::string enum_name;
77 enum_name = name_ +
"Enum";
78 enum_name[0] = toupper(enum_name[0]);
79 *proto_file << enum_name;
83 *proto_file << type_to_protobuf_type(
type());
86 *proto_file <<
" " << name_ <<
" = " << sequence_number;
91 double max_tmp = max();
93 *proto_file << (count ?
", " :
" [");
95 *proto_file <<
"(dccl.field).max=" 96 << goby::util::as<std::string>(max_tmp, precision(), goby::util::FLOAT_FIXED);
103 double min_tmp = min();
104 *proto_file << (count ?
", " :
" [");
106 *proto_file <<
"(dccl.field).min=" 107 << goby::util::as<std::string>(min_tmp, precision(), goby::util::FLOAT_FIXED);
116 int precision_tmp = precision();
117 *proto_file << (count ?
", " :
" [");
119 *proto_file <<
"(dccl.field).precision=" << precision_tmp;
127 unsigned max_length_tmp = max_length();
128 *proto_file << (count ?
", " :
" [");
130 *proto_file <<
"(dccl.field).max_length=" << max_length_tmp;
137 unsigned num_bytes_tmp = num_bytes();
138 *proto_file << (count ?
", " :
" [");
140 *proto_file <<
"(dccl.field).max_length=" << num_bytes_tmp;
147 std::string static_val_tmp = static_val();
148 *proto_file << (count ?
", " :
" [");
150 *proto_file <<
"default=\"" << static_val_tmp <<
"\", (dccl.field).static_value=\"" 151 << static_val_tmp <<
"\", " 152 <<
"(dccl.field).codec=\"_static\"";
158 if (array_length_ != 1)
160 *proto_file << (count ?
", " :
" [");
162 *proto_file <<
"(dccl.field).max_repeat=" << array_length_;
165 std::string more_options = additional_option_extensions();
166 if (!more_options.empty())
168 *proto_file << (count ?
", " :
" [");
170 *proto_file << more_options;
176 *proto_file <<
";" << std::endl;
181 <<
"enum " << enum_name <<
"{ \n";
184 BOOST_FOREACH (
const std::string& e, *enums())
185 *proto_file <<
"\t\t " << boost::to_upper_copy(name_) <<
"_" << e <<
" = " 186 << enum_value++ <<
"; \n";
188 *proto_file <<
"\t} \n";
DCCLCppType type() const
what type is the original type of this DCCLMessageVal?
The global namespace for the Goby project.