descriptions-manager.h
Go to the documentation of this file.
00001 /*
00002         Aseba - an event-based framework for distributed robot control
00003         Copyright (C) 2007--2012:
00004                 Stephane Magnenat <stephane at magnenat dot net>
00005                 (http://stephane.magnenat.net)
00006                 and other contributors, see authors.txt for details
00007         
00008         This program is free software: you can redistribute it and/or modify
00009         it under the terms of the GNU Lesser General Public License as published
00010         by the Free Software Foundation, version 3 of the License.
00011         
00012         This program 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 Lesser General Public License for more details.
00016         
00017         You should have received a copy of the GNU Lesser General Public License
00018         along with this program. If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #ifndef ASEBA_DESCRIPTIONS_MANAGER_H
00022 #define ASEBA_DESCRIPTIONS_MANAGER_H
00023 
00024 #include "msg.h"
00025 #include <string>
00026 
00027 namespace Aseba
00028 {
00031         
00034         class DescriptionsManager
00035         {
00036         protected:
00038                 struct NodeDescription: public TargetDescription
00039                 {
00040                         NodeDescription();
00041                         NodeDescription(const TargetDescription& targetDescription);
00042                         
00043                         unsigned namedVariablesReceptionCounter; 
00044                         unsigned localEventsReceptionCounter; 
00045                         unsigned nativeFunctionReceptionCounter; 
00046                 };
00048                 typedef std::map<unsigned, NodeDescription> NodesDescriptionsMap;
00049                 NodesDescriptionsMap nodesDescriptions; 
00050                 
00051         public:
00053                 virtual ~DescriptionsManager() {}
00054                 
00056                 void processMessage(const Message* message);
00057                 
00059                 std::wstring getNodeName(unsigned nodeId) const;
00061                 unsigned getNodeId(const std::wstring& name, unsigned preferedId = 0, bool *ok = 0) const;
00063                 const TargetDescription * const getDescription(unsigned nodeId, bool *ok = 0) const;
00065                 unsigned getVariablePos(unsigned nodeId, const std::wstring& name, bool *ok = 0) const;
00067                 unsigned getVariableSize(unsigned nodeId, const std::wstring& name, bool *ok = 0) const;
00069                 void reset();
00070                 
00071                 // TODO: reverse lookup?
00072                 // TODO: move bytecode sender manager here, rename class?
00073                 
00074         protected:
00076                 void checkIfNodeDescriptionComplete(unsigned id, const NodeDescription& description);
00077                 
00079                 virtual void nodeProtocolVersionMismatch(const std::wstring &nodeName, uint16 protocolVersion) { }
00080                 
00082                 virtual void nodeDescriptionReceived(unsigned nodeId) { }
00083         };
00084         
00086 }
00087 
00088 #endif


aseba
Author(s): Stéphane Magnenat
autogenerated on Thu Jan 2 2014 11:17:16