Note: Goby version 1 (shown here) is now considered obsolete. Please use version 2 for new projects, and consider upgrading old projects.

Goby Underwater Autonomy Project  Series: 1.1, revision: 163, released on 2013-02-06 14:23:27 -0500
acomms/libdccl/message_algorithms.h
00001 // copyright 2008, 2009 t. schneider tes@mit.edu
00002 // 
00003 // this file is part of the Dynamic Compact Control Language (DCCL),
00004 // the goby-acomms codec. goby-acomms is a collection of libraries 
00005 // for acoustic underwater networking
00006 //
00007 // This program is free software: you can redistribute it and/or modify
00008 // it under the terms of the GNU General Public License as published by
00009 // the Free Software Foundation, either version 3 of the License, or
00010 // (at your option) any later version.
00011 //
00012 // This software is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this software.  If not, see <http://www.gnu.org/licenses/>.
00019 
00020 #ifndef MESSAGE_ALGORITHMS20091211H
00021 #define MESSAGE_ALGORITHMS20091211H
00022 
00023 #include <map>
00024 #include <string>
00025 #include <vector>
00026 #include <iostream>
00027 #include <cctype>
00028 
00029 #include <boost/algorithm/string.hpp>
00030 #include <boost/function.hpp>
00031 namespace goby
00032 {
00033     namespace acomms
00034     {
00035         class DCCLMessageVal;
00036         class DCCLMessage;
00037     
00041         typedef boost::function<void (DCCLMessageVal&)> AlgFunction1;
00045         typedef boost::function<void (DCCLMessageVal&, const std::vector<DCCLMessageVal>&)> AlgFunction2;
00046 
00047         class DCCLAlgorithmPerformer
00048         {
00049           public:
00050             static DCCLAlgorithmPerformer* getInstance();
00051 
00052             void algorithm(DCCLMessageVal& in, unsigned array_index, const std::string& algorithm, const std::map<std::string,std::vector<DCCLMessageVal> >& vals);
00053         
00054             void add_algorithm(const std::string& name, AlgFunction1 func)
00055             { adv_map1_[name] = func; }
00056 
00057             void add_algorithm(const std::string& name, AlgFunction2 func)
00058             { adv_map2_[name] = func; }
00059 
00060             void check_algorithm(const std::string& alg, const DCCLMessage& msg);
00061 
00062           private:
00063             static DCCLAlgorithmPerformer* inst_;
00064             std::map<std::string, AlgFunction1> adv_map1_;
00065             std::map<std::string, AlgFunction2> adv_map2_;
00066         
00067             DCCLAlgorithmPerformer()
00068             {}
00069         
00070             DCCLAlgorithmPerformer(const DCCLAlgorithmPerformer&);
00071             DCCLAlgorithmPerformer& operator = (const DCCLAlgorithmPerformer&);
00072 
00073             
00074         };
00075     }
00076 }
00077 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends