libmoldeo (Moldeo 1.0 Core)
1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
moDeviceCode.cpp
Go to the documentation of this file.
1
/*******************************************************************************
2
3
moDeviceCode.cpp
4
5
****************************************************************************
6
* *
7
* This source is free software; you can redistribute it and/or modify *
8
* it under the terms of the GNU General Public License as published by *
9
* the Free Software Foundation; either version 2 of the License, or *
10
* (at your option) any later version. *
11
* *
12
* This code is distributed in the hope that it will be useful, but *
13
* WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15
* General Public License for more details. *
16
* *
17
* A copy of the GNU General Public License is available on the World *
18
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19
* obtain it by writing to the Free Software Foundation, *
20
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21
* *
22
****************************************************************************
23
24
Copyright(C) 2006 Fabricio Costa
25
26
Authors:
27
Fabricio Costa
28
29
30
*******************************************************************************/
31
32
#include "
moDeviceCode.h
"
33
34
35
//CODIGO DISPOSITIVO
36
37
moDeviceCode::moDeviceCode
() {
38
device
= -1;
39
devicecode
= -1;
40
value
= 0;
41
next
= NULL;
42
previous
= NULL;
43
}
44
45
moDeviceCode::moDeviceCode
(
MOint
did,
MOint
cod,
MOint
val) {
46
device
= did;
47
devicecode
= cod;
48
value
= val;
49
next
= NULL;
50
previous
= NULL;
51
}
52
53
55
56
moDeviceCodeList::moDeviceCodeList
() {
57
First
= NULL;
58
Last
= NULL;
59
}
60
61
moDeviceCodeList::~moDeviceCodeList
() {
62
Finish
();
63
}
64
65
void
66
moDeviceCodeList::Add
(
MOint
did,
MOint
cod,
MOint
value) {
67
if
(
First
==NULL) {
//lista vacia
68
First
=
new
moDeviceCode
(did,cod,value);
69
Last
=
First
;
70
First
->
previous
= NULL;
71
First
->
next
= NULL;
72
}
else
{
//no vacia, lo ponemos al final
73
Last
->
next
=
new
moDeviceCode
(did,cod,value);
74
if
(
Last
->
next
!= NULL) {
75
Last
->
next
->
previous
=
Last
;
76
Last
=
Last
->
next
;
77
}
78
}
79
80
}
81
82
83
//este code es el mismo que el de events
84
//fue revisado
85
MOboolean
86
moDeviceCodeList::Delete
(
moDeviceCode
*ev) {
87
if
(ev==
First
) {
88
if
(ev==
Last
) {
89
First
= NULL;
90
Last
= NULL;
91
}
else
{
92
First
->
next
->
previous
= NULL;
93
First
=
First
->
next
;
94
}
95
}
else
if
(ev==
Last
) {
96
//el caso un solo nodo ya fue visto arriba
97
Last
->
previous
->
next
= NULL;
98
Last
=
Last
->
previous
;
99
}
else
{
100
ev->
previous
->
next
= ev->
next
;
101
ev->
next
->
previous
= ev->
previous
;
102
103
}
104
//finalmente, lo borro al maldito
105
delete
ev;
106
ev = NULL;
107
//por si las dudas podes chequear que este bien muerto;
108
if
(ev == NULL)
return
true
;
109
return
false
;
110
111
}
112
113
MOboolean
114
moDeviceCodeList::Init
() {
115
First
= NULL;
116
Last
= NULL;
117
return
true
;
118
}
119
120
MOboolean
121
moDeviceCodeList::Finish
() {
122
123
while
(
First
!=NULL)
Delete
(
First
);
124
return
true
;
125
}
126
127
void
128
moDeviceCodeList::Copy
(
moDeviceCodeList
*copy) {
129
130
moDeviceCode
*act;
131
132
//borramos nuestro contenido, igualmente
133
while
(
First
!=NULL)
Delete
(
First
);
134
135
act = copy->
First
;
136
while
(act!=NULL) {
137
Add
(act->
device
,act->
devicecode
,act->
value
);
138
act = act->
next
;
139
}
140
141
}
142
moDeviceCode
Definition:
moDeviceCode.h:38
moDeviceCodeList::~moDeviceCodeList
virtual ~moDeviceCodeList()
Definition:
moDeviceCode.cpp:61
moDeviceCodeList::Last
moDeviceCode * Last
Definition:
moDeviceCode.h:54
MOboolean
#define MOboolean
Definition:
moTypes.h:385
moDeviceCodeList::Finish
MOboolean Finish()
Finaliza el objeto, libera recursos.
Definition:
moDeviceCode.cpp:121
moDeviceCodeList::Init
MOboolean Init()
Inicializa el objeto.
Definition:
moDeviceCode.cpp:114
moDeviceCode::next
moDeviceCode * next
Definition:
moDeviceCode.h:43
moDeviceCodeList
Definition:
moDeviceCode.h:50
moDeviceCodeList::First
moDeviceCode * First
Definition:
moDeviceCode.h:53
moDeviceCodeList::Delete
MOboolean Delete(moDeviceCode *)
Definition:
moDeviceCode.cpp:86
moDeviceCode::devicecode
MOint devicecode
Definition:
moDeviceCode.h:41
moDeviceCode::moDeviceCode
moDeviceCode()
Definition:
moDeviceCode.cpp:37
moDeviceCodeList::Add
void Add(MOint, MOint, MOint=0)
Definition:
moDeviceCode.cpp:66
MOint
#define MOint
Definition:
moTypes.h:388
moDeviceCodeList::Copy
void Copy(moDeviceCodeList *)
Definition:
moDeviceCode.cpp:128
moDeviceCode::value
MOint value
Definition:
moDeviceCode.h:42
moDeviceCodeList::moDeviceCodeList
moDeviceCodeList()
CODIGO DISPOSITIVO LISTA.
Definition:
moDeviceCode.cpp:56
moDeviceCode.h
moDeviceCode::previous
moDeviceCode * previous
Definition:
moDeviceCode.h:44
moDeviceCode::device
MOint device
Definition:
moDeviceCode.h:40
libmoldeo
moDeviceCode.cpp
Generated on Wed May 17 2017 14:09:17 for libmoldeo (Moldeo 1.0 Core) by
1.8.8