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