Goby v2
message_algorithms.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 MESSAGE_ALGORITHMS20091211H
24 #define MESSAGE_ALGORITHMS20091211H
25 
26 #include <cctype>
27 #include <iostream>
28 #include <map>
29 #include <string>
30 #include <vector>
31 
32 #include <boost/algorithm/string.hpp>
33 #include <boost/function.hpp>
34 namespace goby
35 {
36 namespace transitional
37 {
38 class DCCLMessageVal;
40 
44 typedef boost::function<void(DCCLMessageVal&)> AlgFunction1;
48 typedef boost::function<void(DCCLMessageVal&, const std::vector<DCCLMessageVal>&)> AlgFunction2;
49 
51 {
52  public:
53  static DCCLAlgorithmPerformer* getInstance();
54  static void deleteInstance();
55 
56  void algorithm(DCCLMessageVal& in, unsigned array_index, const std::string& algorithm,
57  const std::map<std::string, std::vector<DCCLMessageVal> >& vals);
58 
59  void run_algorithm(const std::string& algorithm, DCCLMessageVal& in,
60  const std::vector<DCCLMessageVal>& ref);
61 
62  void add_algorithm(const std::string& name, AlgFunction1 func) { adv_map1_[name] = func; }
63 
64  void add_adv_algorithm(const std::string& name, AlgFunction2 func) { adv_map2_[name] = func; }
65 
66  void check_algorithm(const std::string& alg, const DCCLMessage& msg);
67 
68  private:
69  static DCCLAlgorithmPerformer* inst_;
70  std::map<std::string, AlgFunction1> adv_map1_;
71  std::map<std::string, AlgFunction2> adv_map2_;
72 
74 
77 };
78 } // namespace transitional
79 } // namespace goby
80 
81 #endif
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.
boost::function< void(DCCLMessageVal &)> AlgFunction1
boost::function for a function taking a single DCCLMessageVal reference. Used for algorithm callbacks...