#include <OSGLog.h>
Public Types | |
| typedef void(* | Callback )(const Char8 *data, Int32 size, void *clientData) |
Public Member Functions | |
Constructors | |
| * | LogBuf (UInt32 bufferSize=1024) |
| LogBuf (const LogBuf &) | |
Destructors | |
| *virtual | ~LogBuf () |
Class Specific | |
| *bool | getEnabled (void) |
| void | setEnabled (bool value=true) |
| void | clearChunkBag (void) |
| clear the chunk bag | |
Callback handling | |
| *void | setCallback (Callback cb, void *clientData=0, bool flushData=false) |
| void | removeCallback (void) |
Private Member Functions | |
| const LogBuf & | operator= (const LogBuf &) |
| void | write (const Char8 *buffer, std::streamsize size) |
Callback handling | |
| *virtual Int32 | overflow (Int32 c) |
| virtual Int32 | sync (void) |
| virtual std::streamsize | xsputn (const Char8 *buffer, std::streamsize size) |
Private Attributes | |
| bool | _enabled |
| std::list< Chunk * > | _chunkBag |
| Callback | _callback |
| void * | _clientData |
Classes | |
| struct | Chunk |
Definition at line 137 of file OSGLog.h.
|
|
|
|
|
Definition at line 71 of file OSGLog.cpp. 00071 : 00072 std::streambuf( ), 00073 _enabled (true), 00074 _chunkBag ( ), 00075 _callback (NULL), 00076 _clientData (NULL) 00077 { 00078 setg(0, 0, 0); 00079 00080 if(bufferSize > 0) 00081 { 00082 Char8 *buffer = new Char8[bufferSize]; 00083 00084 setp(buffer, buffer + bufferSize - 1); 00085 } 00086 else 00087 { 00088 setp(0, 0); 00089 } 00090 }
|
|
|
|
|
|
Definition at line 92 of file OSGLog.cpp. References _callback. 00093 { 00094 delete [] pbase(); 00095 00096 _callback = NULL; 00097 }
|
|
|
Definition at line 99 of file OSGLog.inl. References _enabled. 00100 { 00101 return _enabled; 00102 }
|
|
|
Definition at line 106 of file OSGLog.inl. References _enabled.
|
|
|
Definition at line 102 of file OSGLog.cpp. References _chunkBag. 00103 { 00104 std::list<LogBuf::Chunk*>::iterator cI; 00105 00106 for(cI = _chunkBag.begin(); cI != _chunkBag.end(); ++cI) 00107 delete *cI; 00108 00109 _chunkBag.clear(); 00110 }
|
|
||||||||||||||||
|
Definition at line 113 of file OSGLog.cpp. References _callback, _chunkBag, _clientData, osg::LogBuf::Chunk::data, and osg::LogBuf::Chunk::size. 00115 { 00116 std::list<LogBuf::Chunk*>::iterator cI; 00117 LogBuf::Chunk *chunk; 00118 00119 if(cb) 00120 { 00121 if(flushData) 00122 { 00123 for(cI = _chunkBag.begin(); cI != _chunkBag.end(); cI++) 00124 { 00125 if((chunk = *cI)) 00126 cb(chunk->data,chunk->size,clientData); 00127 } 00128 } 00129 00130 _callback = cb; 00131 _clientData = clientData; 00132 } 00133 }
|
|
|
Definition at line 136 of file OSGLog.cpp. References _callback. 00137 { 00138 _callback = 0; 00139 }
|
|
|
|
|
||||||||||||
|
Definition at line 142 of file OSGLog.cpp. References _callback, _chunkBag, _clientData, _enabled, osg::LogBuf::Chunk::data, and osg::LogBuf::Chunk::size. Referenced by overflow(), sync(), and xsputn(). 00143 { 00144 Chunk *chunk = 0; 00145 Callback cb = NULL; 00146 00147 if(_enabled) 00148 { 00149 chunk = new Chunk; 00150 00151 chunk->size = size; 00152 chunk->data = new Char8[size]; 00153 00154 memcpy(chunk->data, buffer, size); 00155 00156 _chunkBag.push_back(chunk); 00157 } 00158 00159 if ((cb = _callback)) 00160 cb(buffer,size, _clientData); 00161 }
|
|
|
Definition at line 163 of file OSGLog.cpp. References write(). 00164 { 00165 if(!pptr()) 00166 return EOF; 00167 00168 if(c != EOF) 00169 { 00170 // Put character into write buffer 00171 *pptr() = c; 00172 00173 pbump(1); 00174 00175 // Flush write buffer 00176 std::streamsize size = pptr() - pbase(); 00177 00178 if(size > 0) 00179 { 00180 write(pbase(), size); 00181 pbump(-size); 00182 } 00183 } 00184 00185 return 0; 00186 }
|
|
|
Definition at line 188 of file OSGLog.cpp. References write(). 00189 { 00190 if(!pptr()) 00191 return EOF; 00192 00193 // Flush write buffer 00194 std::streamsize size = pptr() - pbase(); 00195 00196 if(size > 0) 00197 { 00198 write(pbase(), size); 00199 pbump(-size); 00200 } 00201 00202 return 0; 00203 }
|
|
||||||||||||
|
Definition at line 205 of file OSGLog.cpp. References write(). 00206 { 00207 if(size > 0) 00208 { 00209 if(!pptr()) 00210 return 0; 00211 00212 std::streamsize s = epptr() - pptr(); 00213 00214 if(s >= size) 00215 { 00216 // Put it into the write buffer 00217 memcpy(pptr(), buffer, size); 00218 pbump(size); 00219 } 00220 else 00221 { 00222 // Flush write buffer 00223 s = pptr() - pbase(); 00224 00225 if (s > 0) 00226 { 00227 write(pbase(), s); 00228 pbump(-s); 00229 } 00230 00231 // Write data 00232 write(buffer, size); 00233 } 00234 } 00235 00236 return size; 00237 }
|
|
|
Definition at line 198 of file OSGLog.h. Referenced by getEnabled(), setEnabled(), and write(). |
|
|
Definition at line 200 of file OSGLog.h. Referenced by clearChunkBag(), setCallback(), and write(). |
|
|
Definition at line 202 of file OSGLog.h. Referenced by removeCallback(), setCallback(), write(), and ~LogBuf(). |
|
|
Definition at line 203 of file OSGLog.h. Referenced by setCallback(), and write(). |
1.4.3