~tes/goby/2.0-drc

« back to all changes in this revision

Viewing changes to src/moos/dynamic_moos_vars.h

  • Committer: Toby Schneider
  • Date: 2014-04-22 20:34:48 UTC
  • mfrom: (458.1.81 2.0)
  • Revision ID: tes.aubergine@gmail.com-20140422203448-e1yw2rdhtugywj8z
MergeĀ fromĀ 2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2009-2013 Toby Schneider (https://launchpad.net/~tes)
2
 
//                     Massachusetts Institute of Technology (2007-)
3
 
//                     Woods Hole Oceanographic Institution (2007-)
 
1
// Copyright 2009-2014 Toby Schneider (https://launchpad.net/~tes)
 
2
//                     GobySoft, LLC (2013-)
 
3
//                     Massachusetts Institute of Technology (2007-2014)
4
4
//                     Goby Developers Team (https://launchpad.net/~goby-dev)
5
5
// 
6
6
//
7
 
// This file is part of the Goby Underwater Autonomy Project MOOS Interface Library
8
 
// ("The Goby MOOS Library").
 
7
// This file is part of the Goby Underwater Autonomy Project Libraries
 
8
// ("The Goby Libraries").
9
9
//
10
 
// The Goby MOOS Library is free software: you can redistribute it and/or modify
11
 
// it under the terms of the GNU General Public License as published by
12
 
// the Free Software Foundation, either version 3 of the License, or
 
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
13
// (at your option) any later version.
14
14
//
15
 
// The Goby MOOS Library is distributed in the hope that it will be useful,
 
15
// The Goby Libraries are distributed in the hope that they will be useful,
16
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
// GNU General Public License for more details.
 
18
// GNU Lesser General Public License for more details.
19
19
//
20
 
// You should have received a copy of the GNU General Public License
 
20
// You should have received a copy of the GNU Lesser General Public License
21
21
// along with Goby.  If not, see <http://www.gnu.org/licenses/>.
22
22
 
23
23
 
 
24
 
24
25
#ifndef DYNAMICMOOSVARSH
25
26
#define DYNAMICMOOSVARSH
26
27
 
27
 
#include "MOOSLIB/MOOSLib.h"
 
28
#include "goby/moos/moos_header.h"
28
29
 
29
 
namespace tes
 
30
namespace goby
30
31
{
31
 
    class DynamicMOOSVars
 
32
    namespace moos
32
33
    {
33
 
    public:
34
 
        const CMOOSMsg & get_moos_var(const std::string& s)
35
 
        { return vars[s]; }
36
 
        
37
 
        const CMOOSMsg & operator[](const std::string& s)
38
 
        { return vars[s]; }
39
 
    
40
 
        // read the whole list
41
 
        void update_moos_vars(const MOOSMSG_LIST& NewMail)
 
34
        class DynamicMOOSVars
 
35
        {
 
36
          public:
 
37
            const CMOOSMsg & get_moos_var(const std::string& s)
 
38
            { return vars[s]; }
 
39
                
 
40
            const CMOOSMsg & operator[](const std::string& s)
 
41
            { return vars[s]; }
 
42
                
 
43
            // read the whole list
 
44
            void update_moos_vars(const MOOSMSG_LIST& NewMail)
42
45
            {
43
46
                for(MOOSMSG_LIST::const_iterator p = NewMail.begin(), n = NewMail.end(); p != n; ++p)
44
47
                    vars[p->GetKey()] = *p;
45
48
            }
46
 
 
47
 
        // update a single variable at a time
48
 
        void update_moos_vars(const CMOOSMsg& msg)
 
49
                
 
50
            // update a single variable at a time
 
51
            void update_moos_vars(const CMOOSMsg& msg)
49
52
            { vars[msg.GetKey()] = msg; }
50
 
 
51
 
        std::map<std::string, CMOOSMsg>& all() { return vars; }
52
 
        
53
 
    private:
54
 
        std::map<std::string, CMOOSMsg> vars;
55
 
 
56
 
    };
 
53
                
 
54
            std::map<std::string, CMOOSMsg>& all() { return vars; }
 
55
                
 
56
          private:
 
57
            std::map<std::string, CMOOSMsg> vars;
 
58
                
 
59
        };
 
60
    }
57
61
}
58
62
 
59
63
inline bool valid(const CMOOSMsg& m)