Subversion Repositories HomeAutomation

Rev

Rev 1598 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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