Goby3  3.1.5
2024.05.14
dynamic_moos_vars.h
Go to the documentation of this file.
1 // Copyright 2011-2021:
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 // Community contributors (see AUTHORS file)
5 // File authors:
6 // Toby Schneider <toby@gobysoft.org>
7 //
8 //
9 // This file is part of the Goby Underwater Autonomy Project Libraries
10 // ("The Goby Libraries").
11 //
12 // The Goby Libraries are free software: you can redistribute them and/or modify
13 // them under the terms of the GNU Lesser General Public License as published by
14 // the Free Software Foundation, either version 2.1 of the License, or
15 // (at your option) any later version.
16 //
17 // The Goby Libraries are distributed in the hope that they will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public License
23 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
24 
25 #ifndef GOBY_MOOS_DYNAMIC_MOOS_VARS_H
26 #define GOBY_MOOS_DYNAMIC_MOOS_VARS_H
27 
28 #include "goby/moos/moos_header.h"
29 
30 namespace goby
31 {
32 namespace moos
33 {
35 {
36  public:
37  const CMOOSMsg& get_moos_var(const std::string& s) { return vars[s]; }
38 
39  const CMOOSMsg& operator[](const std::string& s) { return vars[s]; }
40 
41  // read the whole list
42  void update_moos_vars(const MOOSMSG_LIST& NewMail)
43  {
44  for (const auto& p : NewMail) vars[p.GetKey()] = p;
45  }
46 
47  // update a single variable at a time
48  void update_moos_vars(const CMOOSMsg& msg) { vars[msg.GetKey()] = msg; }
49 
50  std::map<std::string, CMOOSMsg>& all() { return vars; }
51 
52  private:
53  std::map<std::string, CMOOSMsg> vars;
54 };
55 } // namespace moos
56 } // namespace goby
57 
58 inline bool valid(const CMOOSMsg& m) { return m.GetTime() != -1; }
59 
60 #endif
goby::moos::DynamicMOOSVars::all
std::map< std::string, CMOOSMsg > & all()
Definition: dynamic_moos_vars.h:50
goby::moos::DynamicMOOSVars::operator[]
const CMOOSMsg & operator[](const std::string &s)
Definition: dynamic_moos_vars.h:39
goby
The global namespace for the Goby project.
Definition: acomms_constants.h:33
goby::moos::DynamicMOOSVars::get_moos_var
const CMOOSMsg & get_moos_var(const std::string &s)
Definition: dynamic_moos_vars.h:37
moos_header.h
CMOOSMsg
valid
bool valid(const CMOOSMsg &m)
Definition: dynamic_moos_vars.h:58
goby::moos::DynamicMOOSVars
Definition: dynamic_moos_vars.h:34
goby::msg
extern ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MessageOptions, ::google::protobuf::internal::MessageTypeTraits< ::goby::GobyMessageOptions >, 11, false > msg
Definition: option_extensions.pb.h:1327
goby::moos::DynamicMOOSVars::update_moos_vars
void update_moos_vars(const CMOOSMsg &msg)
Definition: dynamic_moos_vars.h:48
goby::moos::DynamicMOOSVars::update_moos_vars
void update_moos_vars(const MOOSMSG_LIST &NewMail)
Definition: dynamic_moos_vars.h:42