Goby v2
tags.h
1 // Copyright 2009-2018 Toby Schneider (http://gobysoft.org/index.wt/people/toby)
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 // Community contributors (see AUTHORS file)
5 //
6 //
7 // This file is part of the Goby Underwater Autonomy Project Libraries
8 // ("The Goby Libraries").
9 //
10 // The Goby Libraries are free software: you can redistribute them and/or modify
11 // them under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 2.1 of the License, or
13 // (at your option) any later version.
14 //
15 // The Goby Libraries are distributed in the hope that they will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
22 
23 #ifndef XMLTags20091211H
24 #define XMLTags20091211H
25 
26 #include "goby/moos/transitional/xml/xerces_strings.h"
27 
28 #include <boost/assign.hpp>
29 
30 namespace goby
31 {
32 namespace transitional
33 {
34 namespace xml
35 {
36 enum Tag
37 {
38  tag_not_defined,
39  tag_all,
40  tag_array_length,
41  tag_bool,
42  tag_delta_encode,
43  tag_enum,
44  tag_max_delta,
45  tag_float,
46  tag_format,
47  tag_hex,
48  tag_id,
49  tag_incoming_hex_moos_var,
50  tag_int,
51  tag_key,
52  tag_layout,
53  tag_max_length,
54  tag_max,
55  tag_message_var,
56  tag_message,
57  tag_min,
58  tag_moos_var,
59  tag_name,
60  tag_num_bytes,
61  tag_outgoing_hex_moos_var,
62  tag_precision,
63  tag_publish,
64  tag_publish_var,
65  tag_repeat,
66  tag_size,
67  tag_source,
68  tag_src_var,
69  tag_static,
70  tag_string,
71  tag_trigger_var,
72  tag_trigger_time,
73  tag_trigger,
74  tag_value,
75  tag_time,
76  tag_src_id,
77  tag_dest_id,
78  tag_destination_var,
79  tag_ack,
80  tag_blackout_time,
81  tag_max_queue,
82  tag_newest_first,
83  tag_priority_base,
84  tag_priority_time_const,
85  tag_ttl,
86  tag_value_base
87 };
88 
89 static void initialize_tags(std::map<std::string, Tag>& tags_map)
90 {
91  boost::assign::insert(tags_map)("all", tag_all)("array_length", tag_array_length)(
92  "bool", tag_bool)("delta_encode", tag_delta_encode)("enum", tag_enum)(
93  "max_delta", tag_max_delta)("float", tag_float)("format", tag_format)("hex", tag_hex)(
94  "id", tag_id)("incoming_hex_moos_var", tag_incoming_hex_moos_var)("int", tag_int)(
95  "key", tag_key)("layout", tag_layout)("num_bytes", tag_num_bytes)(
96  "max_length", tag_max_length)("max", tag_max)("message_var", tag_message_var)(
97  "message", tag_message)("min", tag_min)("moos_var", tag_moos_var)("name", tag_name)(
98  "outgoing_hex_moos_var", tag_outgoing_hex_moos_var)("precision", tag_precision)(
99  "publish", tag_publish)("publish_var", tag_publish_var)("repeat", tag_repeat)(
100  "size", tag_size)("source", tag_source)("src_var", tag_src_var)("static", tag_static)(
101  "string", tag_string)("trigger_moos_var", tag_trigger_var)("trigger_var", tag_trigger_var)(
102  "trigger_time", tag_trigger_time)("trigger", tag_trigger)("value", tag_value)(
103  "time", tag_time)("src_id", tag_src_id)("dest_id", tag_dest_id)(
104  "destination_var", tag_destination_var)("destination_moos_var", tag_destination_var)(
105  "ack", tag_ack)("blackout_time", tag_blackout_time)("max_queue", tag_max_queue)(
106  "newest_first", tag_newest_first)("priority_base", tag_priority_base)(
107  "priority_time_const", tag_priority_time_const)("ttl", tag_ttl)("value_base",
108  tag_value_base);
109 }
110 
111 inline bool in_message_var(std::set<Tag>& parents)
112 {
113  if (parents.count(tag_hex))
114  return true;
115  else if (parents.count(tag_int))
116  return true;
117  else if (parents.count(tag_string))
118  return true;
119  else if (parents.count(tag_float))
120  return true;
121  else if (parents.count(tag_bool))
122  return true;
123  else if (parents.count(tag_static))
124  return true;
125  else if (parents.count(tag_enum))
126  return true;
127  else
128  return false;
129 }
130 inline bool in_header_var(std::set<Tag>& parents)
131 {
132  if (parents.count(tag_time))
133  return true;
134  else if (parents.count(tag_src_id))
135  return true;
136  else if (parents.count(tag_dest_id))
137  return true;
138  else
139  return false;
140 }
141 
142 inline bool in_publish(std::set<Tag>& parents) { return parents.count(tag_publish); }
143 } // namespace xml
144 } // namespace transitional
145 } // namespace goby
146 
147 #endif
The global namespace for the Goby project.