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.
 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 
38  device = -1;
39  devicecode = -1;
40  value = 0;
41  next = NULL;
42  previous = NULL;
43 }
44 
46  device = did;
47  devicecode = cod;
48  value = val;
49  next = NULL;
50  previous = NULL;
51 }
52 
53 
55 
57  First = NULL;
58  Last = NULL;
59 }
60 
62  Finish();
63 }
64 
65 void
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
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
115  First = NULL;
116  Last = NULL;
117  return true;
118 }
119 
120 MOboolean
122 
123  while(First!=NULL) Delete(First);
124  return true;
125 }
126 
127 void
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 
virtual ~moDeviceCodeList()
moDeviceCode * Last
Definition: moDeviceCode.h:54
#define MOboolean
Definition: moTypes.h:385
MOboolean Finish()
Finaliza el objeto, libera recursos.
MOboolean Init()
Inicializa el objeto.
moDeviceCode * next
Definition: moDeviceCode.h:43
moDeviceCode * First
Definition: moDeviceCode.h:53
MOboolean Delete(moDeviceCode *)
MOint devicecode
Definition: moDeviceCode.h:41
void Add(MOint, MOint, MOint=0)
#define MOint
Definition: moTypes.h:388
void Copy(moDeviceCodeList *)
moDeviceCodeList()
CODIGO DISPOSITIVO LISTA.
moDeviceCode * previous
Definition: moDeviceCode.h:44