Goby3 3.2.3
2025.05.13
Loading...
Searching...
No Matches
message_algorithms.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_ALGORITHMS_H
26#define GOBY_MOOS_TRANSITIONAL_MESSAGE_ALGORITHMS_H
27
28#include <map> // for map, map<>::mapped_type
29#include <string> // for string
30#include <utility> // for move
31#include <vector> // for vector
32
33#include <boost/function.hpp> // for function
34
35namespace goby
36{
37namespace moos
38{
39namespace transitional
40{
41class DCCLMessageVal;
42class DCCLMessage;
43
47using AlgFunction1 = boost::function<void(DCCLMessageVal&)>;
51using AlgFunction2 = boost::function<void(DCCLMessageVal&, const std::vector<DCCLMessageVal>&)>;
52
54{
55 public:
57 static void deleteInstance();
58
59 void algorithm(DCCLMessageVal& in, unsigned array_index, const std::string& algorithm,
60 const std::map<std::string, std::vector<DCCLMessageVal> >& vals);
61
62 void run_algorithm(const std::string& algorithm, DCCLMessageVal& in,
63 const std::vector<DCCLMessageVal>& ref);
64
65 void add_algorithm(const std::string& name, AlgFunction1 func)
66 {
67 adv_map1_[name] = std::move(func);
68 }
69
70 void add_adv_algorithm(const std::string& name, AlgFunction2 func)
71 {
72 adv_map2_[name] = std::move(func);
73 }
74
75 void check_algorithm(const std::string& alg, const DCCLMessage& msg);
76
77 private:
78 static DCCLAlgorithmPerformer* inst_;
79 std::map<std::string, AlgFunction1> adv_map1_;
80 std::map<std::string, AlgFunction2> adv_map2_;
81
82 DCCLAlgorithmPerformer() = default;
83
85 DCCLAlgorithmPerformer& operator=(const DCCLAlgorithmPerformer&) = delete;
86};
87} // namespace transitional
88} // namespace moos
89} // namespace goby
90
91#endif
void run_algorithm(const std::string &algorithm, DCCLMessageVal &in, const std::vector< DCCLMessageVal > &ref)
void algorithm(DCCLMessageVal &in, unsigned array_index, const std::string &algorithm, const std::map< std::string, std::vector< DCCLMessageVal > > &vals)
static DCCLAlgorithmPerformer * getInstance()
void check_algorithm(const std::string &alg, const DCCLMessage &msg)
void add_adv_algorithm(const std::string &name, AlgFunction2 func)
void add_algorithm(const std::string &name, AlgFunction1 func)
boost::function< void(DCCLMessageVal &)> AlgFunction1
boost::function for a function taking a single DCCLMessageVal reference. Used for algorithm callbacks...
boost::function< void(DCCLMessageVal &, const std::vector< DCCLMessageVal > &)> AlgFunction2
boost::function for a function taking a dccl::MessageVal reference, and the MessageVal of a second pa...
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