Goby Underwater Autonomy Project
Series: 1.1, revision: 163, released on 2013-02-06 14:23:27 -0500
|
00001 // t. schneider tes@mit.edu 07.02.09 00002 // ocean engineering graudate student - mit / whoi joint program 00003 // massachusetts institute of technology (mit) 00004 // laboratory for autonomous marine sensing systems (lamss) 00005 // 00006 // this is dynamic_moos_vars.hpp 00007 // 00008 // see the readme file within this directory for information 00009 // pertaining to usage and purpose of this script. 00010 // 00011 // This program is free software: you can redistribute it and/or modify 00012 // it under the terms of the GNU General Public License as published by 00013 // the Free Software Foundation, either version 3 of the License, or 00014 // (at your option) any later version. 00015 // 00016 // This software is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU General Public License 00022 // along with this software. If not, see <http://www.gnu.org/licenses/>. 00023 00024 #ifndef DYNAMICMOOSVARSH 00025 #define DYNAMICMOOSVARSH 00026 00027 #include "MOOSLIB/MOOSLib.h" 00028 00029 namespace tes 00030 { 00031 class DynamicMOOSVars 00032 { 00033 public: 00034 const CMOOSMsg & get_moos_var(const std::string& s) 00035 { return vars[s]; } 00036 00037 const CMOOSMsg & operator[](const std::string& s) 00038 { return vars[s]; } 00039 00040 // read the whole list 00041 void update_moos_vars(const MOOSMSG_LIST& NewMail) 00042 { 00043 for(MOOSMSG_LIST::const_iterator p = NewMail.begin(), n = NewMail.end(); p != n; ++p) 00044 vars[p->GetKey()] = *p; 00045 } 00046 00047 // update a single variable at a time 00048 void update_moos_vars(const CMOOSMsg& msg) 00049 { vars[msg.GetKey()] = msg; } 00050 00051 private: 00052 std::map<std::string, CMOOSMsg> vars; 00053 00054 }; 00055 } 00056 00057 inline bool valid(const CMOOSMsg& m) 00058 { return m.GetTime() != -1; } 00059 00060 #endif