Subversion Repositories HomeAutomation

Rev

Rev 1598 | Rev 1627 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. /*
  2.  
  3.     Copyright (C) 2010  Mattias Runge
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License along
  16.     with this program; if not, write to the Free Software Foundation, Inc.,
  17.     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18.  
  19. */
  20.  
  21. #ifndef CAN_NODE_H
  22. #define CAN_NODE_H
  23.  
  24. #include <string>
  25.  
  26. #include <boost/shared_ptr.hpp>
  27.  
  28. #include <time.h>
  29.  
  30. namespace atom {
  31. namespace can {
  32.  
  33. class Node
  34. {
  35. public:
  36.     typedef boost::shared_ptr<Node> Pointer;
  37.     typedef unsigned int Id;
  38.    
  39.     typedef enum
  40.     {
  41.         STATE_OFFLINE,
  42.         STATE_ONLINE,
  43.         STATE_PENDING,
  44.         STATE_INITIALIZED
  45.     } State;
  46.    
  47.     Node(Id id);
  48.     virtual ~Node();
  49.    
  50.     Id GetId();
  51.     State GetState();
  52.     void SetState(State state);
  53.    
  54.     bool CheckTimeout();
  55.     void ResetTimeout();
  56.    
  57. private:
  58.     Id id_;
  59.     State state_;
  60.     time_t last_active_;
  61. };
  62.  
  63. }; // namespace can
  64. }; // namespace atom
  65.  
  66. #endif // CAN_NODE_H
  67.