forked from maczinga/ASOM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Component.h
74 lines (66 loc) · 2.02 KB
/
Component.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
\file Component.h
\brief Class definition for a generic component.
\details This class implements a generic component. All other classes should inherit from it. It implements basic error
management and component identification interface.
\author Enrico Formenti
\version 0.1
\date 2012-2013
\warning This software is provided "as is". The author is
not responsible for any damage of any kind caused by this
software. Use it at your own risk.
\copyright BSD license. See license.txt for more details.
All text above must be included in any redistribution.
*/
#ifndef COMPONENT_H
#define COMPONENT_H
/**
\class Component Component.h
\brief Class for a generic component.
This class implements a generic component. Basically, it implements error management and component identification.
All other classes should inherit from this one.
*/
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
class Component {
protected:
/**
\var uint32_t _id
\brief identifier for the component.
*/
uint32_t _id;
/**
\var uint32_t _type
\brief Identifier for the type of component.
*/
uint32_t _type;
public:
/**
\fn Component(uint32_t i, uint32_t t)
\brief Constructor for a generic component.
@param i Identifier of the component.
@param t Type of the component (temperature sensor, humidity sensor, real time clock, etc.)
*/
inline Component(uint32_t i, uint32_t t) { _id = i; _type = t; }
/**
\fn uint32_t getId(void)
\brief Gets the identifier for this component.
*/
inline uint32_t getId(void) { return _id; }
/**
\fn uint32_t getType(void)
\brief Gets the type of this component.
*/
inline uint32_t getType(void) { return _type; }
/**
\fn boolean isComponent(uint32_t c, uint32_t t)
\brief Tests if this component is the same as \c c.
@param c Identifier of the component.
@param t Type of the component (temperature sensor, humidity sensor, real time clock, etc.)
*/
inline boolean isComponent(uint32_t c, uint32_t t) { return (_id == c)&&(_type == t); }
};
#endif