Changeset 9861 in orxonox.OLD for branches/new_class_id/src
- Timestamp:
- Oct 1, 2006, 1:37:36 PM (18 years ago)
- Location:
- branches/new_class_id/src
- Files:
-
- 8 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/Makefile.am
r9839 r9861 57 57 defs/confincl.h \ 58 58 defs/error.h \ 59 defs/debug.h \60 59 defs/globals.h \ 61 60 defs/compiler.h \ -
branches/new_class_id/src/lib/shell/Makefile.am
r9709 r9861 6 6 libORXshell_a_SOURCES = \ 7 7 shell.cc \ 8 shell_buffer.cc \9 8 shell_input.cc \ 10 9 shell_command.cc \ … … 16 15 noinst_HEADERS= \ 17 16 shell.h \ 18 shell_buffer.h \19 17 shell_input.h \ 20 18 shell_command_class.h \ -
branches/new_class_id/src/lib/shell/shell.cc
r9715 r9861 18 18 #include "shell.h" 19 19 #include "shell_command.h" 20 #include " shell_buffer.h"20 #include "debug_buffer.h" 21 21 #include "shell_input.h" 22 22 … … 65 65 this->setName("Shell"); 66 66 67 this->shellBuffer = ShellBuffer::getInstance();67 this->shellBuffer = DebugBuffer::getInstance(); 68 68 69 69 // EVENT-Handler subscription of '`' to all States. … … 446 446 { 447 447 this->flush(); 448 ShellBuffer::addBufferLineStatic("orxonox - shell\n ==================== \n", NULL);448 DebugBuffer::addBufferLineStatic("orxonox - shell\n ==================== \n", NULL); 449 449 } 450 450 -
branches/new_class_id/src/lib/shell/shell.h
r9715 r9861 14 14 15 15 #include "shell_input.h" 16 #include " shell_buffer.h"16 #include "debug_buffer.h" 17 17 #include "material.h" 18 18 … … 93 93 private: 94 94 // GENERAL 95 ShellBuffer* shellBuffer; //!< The local ShellBuffer.95 DebugBuffer* shellBuffer; //!< The local ShellBuffer. 96 96 97 97 bool bActive; //!< If the shell is active. -
branches/new_class_id/src/lib/shell/shell_input.cc
r9715 r9861 161 161 bool ShellInput::executeCommand() 162 162 { 163 ShellBuffer::addBufferLineStatic("Execute Command: %s\n", this->inputLine.c_str());163 DebugBuffer::addBufferLineStatic("Execute Command: %s\n", this->inputLine.c_str()); 164 164 165 165 if (this->inputLine.empty()) -
branches/new_class_id/src/lib/util/Makefile.am
r9856 r9861 14 14 helper_functions.cc \ 15 15 multi_type.cc \ 16 debug_buffer.cc \ 16 17 \ 17 18 loading/resource_manager.cc \ … … 39 40 color.h \ 40 41 helper_functions.h \ 42 debug.h \ 43 debug_buffer.h \ 41 44 \ 42 45 \ -
branches/new_class_id/src/lib/util/debug.h
r9860 r9861 27 27 28 28 #include "defs/confincl.h" 29 #ifndef NO_ SHELL30 #include " lib/shell/shell_buffer.h"31 #endif /* NO_ SHELL*/29 #ifndef NO_BUFFER 30 #include "debug_buffer.h" 31 #endif /* NO_BUFFER */ 32 32 33 33 #include <stdio.h> … … 114 114 #endif 115 115 #ifndef NO_SHELL 116 #define PRINT_EXEC OrxShell::ShellBuffer::addBufferLineStatic116 #define PRINT_EXEC DebugBuffer::addBufferLineStatic 117 117 #define COUT_EXEC std::cout 118 118 #else /* NO_SHELL */ -
branches/new_class_id/src/lib/util/debug_buffer.cc
r9859 r9861 14 14 */ 15 15 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SHELL 17 18 #include "shell_buffer.h" 16 #include "debug_buffer.h" 19 17 20 18 #include <stdarg.h> … … 22 20 #include "debug.h" 23 21 #include "compiler.h" 24 #include " lib/util/threading.h"22 #include "threading.h" 25 23 26 namespace OrxShell 24 /** 25 * @brief standard constructor 26 */ 27 DebugBuffer::DebugBuffer () 27 28 { 28 /** 29 * @brief standard constructor 30 */ 31 ShellBuffer::ShellBuffer () 32 { 33 ShellBuffer::singletonRef = this; 29 DebugBuffer::singletonRef = this; 34 30 35 36 31 this->lineCount = 0; 32 this->bufferArray[0] = '\0'; 37 33 38 39 34 this->setMaxBufferSize(100); 35 } 40 36 41 ShellBuffer* ShellBuffer::singletonRef = NULL;42 std::list<std::string> ShellBuffer::buffer;43 char ShellBuffer::bufferArray[SHELL_BUFFER_SIZE] = "";37 DebugBuffer* DebugBuffer::singletonRef = NULL; 38 std::list<std::string> DebugBuffer::buffer; 39 char DebugBuffer::bufferArray[DEBUG_BUFFER_SIZE] = ""; 44 40 45 41 46 47 48 49 ShellBuffer::~ShellBuffer ()50 51 ShellBuffer::singletonRef = NULL;52 42 /** 43 * @brief standard deconstructor 44 */ 45 DebugBuffer::~DebugBuffer () 46 { 47 DebugBuffer::singletonRef = NULL; 48 } 53 49 54 55 56 57 void ShellBuffer::flush()58 59 60 50 /** 51 * @brief deletes all the Buffers 52 */ 53 void DebugBuffer::flush() 54 { 55 this->buffer.clear(); 56 } 61 57 62 63 64 65 66 void ShellBuffer::addBufferLineStatic(const char* line, ...)67 68 static OrxThread::Mutex ShellBuffer__bufferMutex;58 /** 59 * @brief adds a new Line to the List of Buffers 60 * @param line the Line as in the first argument in printf 61 */ 62 void DebugBuffer::addBufferLineStatic(const char* line, ...) 63 { 64 static OrxThread::Mutex DebugBuffer__bufferMutex; 69 65 70 OrxThread::MutexLock bufferLock(&ShellBuffer__bufferMutex);66 OrxThread::MutexLock bufferLock(&DebugBuffer__bufferMutex); 71 67 72 73 74 vsnprintf(ShellBuffer::bufferArray, SHELL_BUFFER_SIZE, line, arguments);75 68 va_list arguments; 69 va_start(arguments, line); 70 vsnprintf(DebugBuffer::bufferArray, DEBUG_BUFFER_SIZE, line, arguments); 71 va_end(arguments); 76 72 77 73 #if DEBUG_LEVEL < 3 78 if (ShellBuffer::singletonRef == NULL)74 if (DebugBuffer::singletonRef == NULL) 79 75 #endif 80 printf(ShellBuffer::bufferArray);76 printf(DebugBuffer::bufferArray); 81 77 #if DEBUG_LEVEL < 3 82 78 else 83 79 #else 84 if (ShellBuffer::singletonRef != NULL)80 if (DebugBuffer::singletonRef != NULL) 85 81 #endif 86 ShellBuffer::singletonRef->addBufferLine(ShellBuffer::bufferArray); 82 DebugBuffer::singletonRef->addBufferLine(DebugBuffer::bufferArray); 83 } 84 85 /** 86 * @brief add a Line to the List of Buffers 87 * @param line 88 * @param arguments 89 * 90 * This function Adds one line to the buffer. 91 * and displays the line as the First Line of the display-buffer 92 */ 93 void DebugBuffer::addBufferLine(const char* line) 94 { 95 std::string inputBuffer = this->keepBuffer + line; 96 97 unsigned int lineBegin = 0; 98 unsigned int lineEnd = 0; 99 // adding all the new Lines 100 while (lineEnd < inputBuffer.size()) 101 { 102 lineBegin = lineEnd; 103 lineEnd = inputBuffer.find('\n', (lineBegin == 0) ? 0: ++lineBegin); 104 if (likely(lineEnd != std::string::npos )) 105 { 106 this->lineCount++; 107 this->buffer.push_front(inputBuffer.substr(lineBegin, lineEnd - lineBegin)); 108 } 109 else // No end of Line reached. 110 { 111 this->keepBuffer = inputBuffer.substr(lineBegin, inputBuffer.size() - lineBegin); 112 break; 113 } 114 115 if (inputBuffer[lineBegin] == '\n') 116 lineBegin++, lineEnd++; 117 118 if (this->buffer.size() > this->maxBufferSize) 119 this->buffer.pop_back(); 87 120 } 121 } 88 122 89 /** 90 * @brief add a Line to the List of Buffers 91 * @param line 92 * @param arguments 93 * 94 * This function Adds one line to the buffer. 95 * and displays the line as the First Line of the display-buffer 96 */ 97 void ShellBuffer::addBufferLine(const char* line) 98 { 99 std::string inputBuffer = this->keepBuffer + line; 123 /** 124 * @brief displays some nice output from the Debug 125 */ 126 void DebugBuffer::debug() const 127 { 128 PRINT(3)("Debugging output to console (not this debug)\n"); 100 129 101 unsigned int lineBegin = 0; 102 unsigned int lineEnd = 0; 103 // adding all the new Lines 104 while (lineEnd < inputBuffer.size()) 105 { 106 lineBegin = lineEnd; 107 lineEnd = inputBuffer.find('\n', (lineBegin == 0) ? 0: ++lineBegin); 108 if (likely(lineEnd != std::string::npos )) 109 { 110 this->lineCount++; 111 this->buffer.push_front(inputBuffer.substr(lineBegin, lineEnd - lineBegin)); 112 } 113 else // No end of Line reached. 114 { 115 this->keepBuffer = inputBuffer.substr(lineBegin, inputBuffer.size() - lineBegin); 116 break; 117 } 118 119 if (inputBuffer[lineBegin] == '\n') 120 lineBegin++, lineEnd++; 121 122 if (this->buffer.size() > this->maxBufferSize) 123 this->buffer.pop_back(); 124 } 125 } 126 127 /** 128 * @brief displays some nice output from the Shell 129 */ 130 void ShellBuffer::debug() const 131 { 132 PRINT(3)("Debugging output to console (not this shell)\n"); 133 134 std::list<std::string>::const_iterator bufferLine; 135 for (bufferLine = --this->buffer.end(); bufferLine != this->buffer.begin(); --bufferLine) 136 printf((*bufferLine).c_str()); 137 } 138 130 std::list<std::string>::const_iterator bufferLine; 131 for (bufferLine = --this->buffer.end(); bufferLine != this->buffer.begin(); --bufferLine) 132 printf((*bufferLine).c_str()); 139 133 } -
branches/new_class_id/src/lib/util/debug_buffer.h
r9859 r9861 1 1 /*! 2 * @file shell_buffer.h3 * @brief The Shellbuffer Tasks2 * @file debug_buffer.h 3 * @brief The Debug buffer Tasks 4 4 * @see debug.h 5 5 */ 6 6 7 #ifndef _ SHELL_BUFFER_H8 #define _ SHELL_BUFFER_H7 #ifndef _DEBUG_BUFFER_H 8 #define _DEBUG_BUFFER_H 9 9 10 10 #include <string> 11 11 #include <list> 12 #include <stdarg.h>13 12 14 #define SHELL_BUFFER_SIZE 16384 //!< The Size of the input-buffers (should be large enough to carry any kind of input)13 #define DEBUG_BUFFER_SIZE 16384 //!< The Size of the input-buffers (should be large enough to carry any kind of input) 15 14 16 namespace OrxShell17 {18 15 //! A class handling output from orxonox via debug.h 19 16 /** 20 * the ShellBuffer redirects output from PRINTF(x) to the Shelland STDOUT21 * the ShellBuffer is a front-filling queue of limited length, that has the17 * the DebugBuffer redirects output from PRINTF(x) to the Debug and STDOUT 18 * the DebugBuffer is a front-filling queue of limited length, that has the 22 19 * youngest added Entry at the beginning, and the oldest at the end. 23 20 */ 24 class ShellBuffer21 class DebugBuffer 25 22 { 26 23 public: 27 virtual ~ ShellBuffer();24 virtual ~DebugBuffer(); 28 25 /** @returns a Pointer to the only object of this Class */ 29 inline static ShellBuffer* getInstance() { if (!ShellBuffer::singletonRef) ShellBuffer::singletonRef = new ShellBuffer(); return ShellBuffer::singletonRef; };26 inline static DebugBuffer* getInstance() { if (!DebugBuffer::singletonRef) DebugBuffer::singletonRef = new DebugBuffer(); return DebugBuffer::singletonRef; }; 30 27 /** @returns true if this class is instanciated, false otherwise */ 31 inline static bool isInstanciated() { return ( ShellBuffer::singletonRef == NULL)?false:true; };28 inline static bool isInstanciated() { return (DebugBuffer::singletonRef == NULL)?false:true; }; 32 29 33 30 static void addBufferLineStatic(const char* line, ...); … … 41 38 /** @returns the List of stings from the Buffer */ 42 39 const std::list<std::string>& getBuffer() const { return this->buffer; }; 43 /** @returns the Count of lines processed by the Shell. */40 /** @returns the Count of lines processed by the Debug. */ 44 41 inline unsigned long getLineCount() const { return this->lineCount; }; 45 42 /** @returns the Current Buffer Size. */ … … 49 46 50 47 private: 51 ShellBuffer();48 DebugBuffer(); 52 49 53 50 private: 54 static ShellBuffer* singletonRef; //!< The singleton-reference to the only memeber of this class.55 unsigned int maxBufferSize; 51 static DebugBuffer* singletonRef; //!< The singleton-reference to the only memeber of this class. 52 unsigned int maxBufferSize; //!< The Size of the buffer 56 53 57 std::string keepBuffer; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.54 std::string keepBuffer; //!< a BUFFER to have multi-non-newLine commands be copied into the debug. 58 55 59 56 unsigned long lineCount; //!< how many Lines have been written out so far. 60 57 61 58 // The Beginning of buffer (buffer.front()) is the last added line. 62 static char bufferArray[ SHELL_BUFFER_SIZE]; //!< a BUFFER for fast writing59 static char bufferArray[DEBUG_BUFFER_SIZE]; //!< a BUFFER for fast writing 63 60 static std::list<std::string> buffer; //!< A list of stored char-arrays(strings) to store the history 64 61 }; 65 62 66 } 67 68 #endif /* _SHELL_BUFFER_H */ 63 #endif /* _DEBUG_BUFFER_H */ -
branches/new_class_id/src/orxonox.cc
r9855 r9861 51 51 #include "shell_command_class.h" 52 52 #include "shell_command.h" 53 #include "shell_buffer.h"54 53 55 54 #include "network_manager.h" … … 138 137 Resources::ResourceManager::deleteInstance(); 139 138 // output-buffer 140 delete OrxShell::ShellBuffer::getInstance();139 delete DebugBuffer::getInstance(); 141 140 142 141 SDL_QuitSubSystem(SDL_INIT_TIMER); … … 389 388 int Orxonox::initMisc() 390 389 { 391 OrxShell::ShellBuffer::getInstance();390 DebugBuffer::getInstance(); 392 391 393 392 // start the collision detection engine
Note: See TracChangeset
for help on using the changeset viewer.