Goby3  3.1.5a
2024.05.23
message_publish.h
Go to the documentation of this file.
1 // Copyright 2009-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_TRANSITIONAL_MESSAGE_PUBLISH_H
26 #define GOBY_MOOS_TRANSITIONAL_MESSAGE_PUBLISH_H
27 
28 #include <iostream>
29 #include <sstream>
30 #include <utility>
31 
32 #include <vector>
33 
34 #include <boost/format.hpp>
35 
36 #include "dccl_constants.h"
37 #include "message_algorithms.h"
38 #include "message_val.h"
39 #include "message_var.h"
40 
41 namespace goby
42 {
43 namespace moos
44 {
45 namespace transitional
46 {
47 class DCCLMessage;
48 
49 // defines (a single) thing to do with the decoded message
50 // that is, where do we publish it and what should we include in the
51 // published message
53 {
54  public:
55  DCCLPublish() : var_(""), format_(""), ap_(DCCLAlgorithmPerformer::getInstance()) {}
56 
57  //set
58 
59  void set_var(std::string var) { var_ = std::move(var); }
60  void set_format(std::string format)
61  {
62  format_ = std::move(format);
63  format_set_ = true;
64  }
65  void set_use_all_names(bool use_all_names) { use_all_names_ = use_all_names; }
66  void set_type(DCCLCppType type) { type_ = type; }
67 
68  void add_name(const std::string& name) { names_.push_back(name); }
69  void add_message_var(const std::shared_ptr<DCCLMessageVar>& mv) { message_vars_.push_back(mv); }
70  void add_algorithms(const std::vector<std::string>& algorithms)
71  {
72  algorithms_.push_back(algorithms);
73  }
74 
75  //get
76  std::string var() const { return var_; }
77  std::string format() const { return format_; }
78  bool format_set() const { return format_set_; }
79  bool use_all_names() const { return use_all_names_; }
80 
81  DCCLCppType type() const { return type_; }
82  std::vector<std::shared_ptr<DCCLMessageVar> > const& message_vars() const
83  {
84  return message_vars_;
85  }
86 
87  std::vector<std::string> const& names() const { return names_; }
88  std::vector<std::vector<std::string> > const& algorithms() const { return algorithms_; }
89 
90  void initialize(const DCCLMessage& msg);
91 
92  private:
93  std::string var_;
94  std::string format_;
95  bool format_set_{false};
96  bool use_all_names_{false};
97  DCCLCppType type_{cpp_notype};
98  std::vector<std::string> names_;
99  std::vector<std::shared_ptr<DCCLMessageVar> > message_vars_;
100  std::vector<std::vector<std::string> > algorithms_;
101  DCCLAlgorithmPerformer* ap_;
102  unsigned repeat_{1};
103 };
104 } // namespace transitional
105 } // namespace goby
106 } // namespace goby
107 #endif
message_val.h
goby::moos::transitional::DCCLAlgorithmPerformer
Definition: message_algorithms.h:53
goby
The global namespace for the Goby project.
Definition: acomms_constants.h:33
goby::moos::transitional::DCCLPublish::format
std::string format() const
Definition: message_publish.h:77
message_var.h
goby::moos::transitional::DCCLPublish::set_format
void set_format(std::string format)
Definition: message_publish.h:60
goby::moos::transitional::DCCLPublish::set_type
void set_type(DCCLCppType type)
Definition: message_publish.h:66
dccl_constants.h
goby::moos::transitional::DCCLPublish::add_algorithms
void add_algorithms(const std::vector< std::string > &algorithms)
Definition: message_publish.h:70
goby::moos::transitional::DCCLPublish::algorithms
std::vector< std::vector< std::string > > const & algorithms() const
Definition: message_publish.h:88
goby::moos::transitional::DCCLPublish
Definition: message_publish.h:52
goby::moos::transitional::DCCLPublish::initialize
void initialize(const DCCLMessage &msg)
goby::moos::transitional::DCCLPublish::names
std::vector< std::string > const & names() const
Definition: message_publish.h:87
goby::moos::transitional::DCCLPublish::set_var
void set_var(std::string var)
Definition: message_publish.h:59
goby::moos::transitional::DCCLPublish::add_name
void add_name(const std::string &name)
Definition: message_publish.h:68
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::transitional::DCCLPublish::format_set
bool format_set() const
Definition: message_publish.h:78
goby::moos::transitional::DCCLPublish::DCCLPublish
DCCLPublish()
Definition: message_publish.h:55
goby::moos::transitional::DCCLPublish::add_message_var
void add_message_var(const std::shared_ptr< DCCLMessageVar > &mv)
Definition: message_publish.h:69
goby::moos::transitional::DCCLPublish::set_use_all_names
void set_use_all_names(bool use_all_names)
Definition: message_publish.h:65
goby::moos::transitional::DCCLMessage
Definition: message.h:61
goby::moos::transitional::DCCLCppType
DCCLCppType
Enumeration of C++ types used in DCCL.
Definition: dccl_constants.h:59
goby::moos::transitional::DCCLPublish::use_all_names
bool use_all_names() const
Definition: message_publish.h:79
goby::moos::transitional::DCCLPublish::var
std::string var() const
Definition: message_publish.h:76
message_algorithms.h
goby::moos::transitional::cpp_notype
@ cpp_notype
Definition: dccl_constants.h:61
goby::moos::transitional::DCCLPublish::type
DCCLCppType type() const
Definition: message_publish.h:81
goby::moos::transitional::DCCLPublish::message_vars
std::vector< std::shared_ptr< DCCLMessageVar > > const & message_vars() const
Definition: message_publish.h:82