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
moAbstract.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moAbstract.h
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 #include "moAbstract.h"
32 using namespace std;
33 
35 
36 
38  moStdOut.open ("cout.txt");
39  moErr.open ("moldeoerrors.txt");
40  moLog.open ("moldeolog.txt");
41 
42  backup = cout.rdbuf(); // back up cout's streambuf
43  #ifdef MO_WIN32XX
44  psbuf = moStdOut.rdbuf(); // get file's streambuf
45  cout.rdbuf( psbuf ); // assign streambuf to cout
46  freopen("stdout.txt", "w", stdout);
47  #endif
48 }
49 
51 
52  cout.rdbuf( backup );
53  setbuf(stdout,NULL);
54 
55  moStdOut.close();
56  moErr.close();
57  moLog.close();
58 }
59 
60 void
61 moDebug::SetStdout( const moText& filename ) {
62 
63  moText fname = filename;
64 
65  if (fname.Trim().Length()>0) {
66  moStdOut.open ( fname );
67 
68  psbuf = moStdOut.rdbuf(); // get file's streambuf
69  cout.rdbuf( psbuf ); // assign streambuf to cout
70 
71  freopen( fname, "w", stdout);
72  } else {
73  cout.rdbuf( backup ); // assign streambuf to cout
74  }
75 
76 }
77 
78 void
80  Lock();
81  moText prefx_error = moText("Error! ");
82  //system("Color 04");
83 #ifndef MO_WIN32
84  cout << "\x1b[31;1m" << prefx_error << p_text << "\x1b[0m" << endl;
85  moErr << prefx_error << p_text << endl;
86 #else
87  cout << prefx_error << p_text << endl;
88  moErr << prefx_error << p_text << endl;
89 #endif
90  moLog << prefx_error << p_text << endl;
91  //system("Color 02");
92  m_Debug.Push( prefx_error + p_text );
93  Unlock();
94 }
95 
96 void
98  Lock();
99  moText prefx_error = moText("Warning! ");
100 #ifndef MO_WIN32
101  cout << "\x1b[33;1m" << prefx_error << p_text << "\x1b[0m" << endl;
102  moErr << prefx_error << p_text << endl;
103  moLog << prefx_error << p_text << endl;
104 #else
105  cout << prefx_error << p_text << endl;
106  moErr << prefx_error << p_text << endl;
107  moLog << prefx_error << p_text << endl;
108 #endif
109  m_Debug.Push( prefx_error + p_text );
110  Unlock();
111 }
112 
113 void
115  Lock();
116  cout << p_text << endl;
117  moLog << p_text << endl;
118  m_Debug.Push( p_text );
119  Unlock();
120 }
121 
122 void
123 moDebug::Log( moText p_text ) {
124  Lock();
125  moLog << p_text << endl;
126  Unlock();
127 }
128 
130 
131 
133  //MODebug = NULL;
134  m_bInitialized = false;
135 }
136 
138 }
139 
140 MOboolean
142  m_bInitialized = true;
143  return true;
144 }
145 
146 MOboolean
148  m_bInitialized = false;
149  return true;
150 }
151 
152 MOboolean
154  return m_bInitialized;
155 }
156 
MOboolean Initialized()
Pregunta si está inicializado.
Definition: moAbstract.cpp:153
void SetStdout(const moText &filename=moText(""))
Fija el archivo de salida del flujo estandar de c y c++ (stdout y cout)
Definition: moAbstract.cpp:61
void Error(moText p_text)
Anuncia y registra un error.
Definition: moAbstract.cpp:79
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
Definition: moAbstract.cpp:147
#define MOboolean
Definition: moTypes.h:385
virtual MOboolean Init()
Inicializa el objeto.
Definition: moAbstract.cpp:141
void Warning(moText p_text)
Anuncia y registra un llamado de atencion.
Definition: moAbstract.cpp:97
clase de para manejar textos
Definition: moText.h:75
void Log(moText p_text)
Escribe un mensaje en el archivo de registro (log)
Definition: moAbstract.cpp:123
moText0 & Trim()
Definition: moText.cpp:604
moText0 moText
Definition: moText.h:291
virtual ~moAbstract()
Definition: moAbstract.cpp:137
MOuint Length() const
Definition: moText.cpp:347
lista de textos
Definition: moText.h:306
static moDebug * MODebug2
Clase de impresión de errores para depuración
Definition: moAbstract.h:225
virtual ~moDebug()
Definition: moAbstract.cpp:50
static moTextHeap * MODebug
Lista de textos.
Definition: moAbstract.h:226
void Message(moText p_text)
Anuncia un mensaje al usuario además de guardarlo en el log de texto.
Definition: moAbstract.cpp:114
Lista de mensajes para la depuración de errores y anuncio de errores y mensajes.
Definition: moAbstract.h:47