Goby3 3.2.3
2025.05.13
Loading...
Searching...
No Matches
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
41namespace goby
42{
43namespace moos
44{
45namespace transitional
46{
47class 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
91
92 private:
93 std::string var_;
94 std::string format_;
95 bool format_set_{false};
96 bool use_all_names_{false};
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
void add_algorithms(const std::vector< std::string > &algorithms)
void set_use_all_names(bool use_all_names)
std::vector< std::shared_ptr< DCCLMessageVar > > const & message_vars() const
void add_name(const std::string &name)
std::vector< std::string > const & names() const
void initialize(const DCCLMessage &msg)
std::vector< std::vector< std::string > > const & algorithms() const
void add_message_var(const std::shared_ptr< DCCLMessageVar > &mv)
void set_format(std::string format)
DCCLCppType
Enumeration of C++ types used in DCCL.
The global namespace for the Goby project.
extern ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::PROTOBUF_NAMESPACE_ID::MessageOptions, ::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::goby::GobyMessageOptions >, 11, false > msg