Changeset 5206 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Sep 19, 2005, 12:31:56 AM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell.cc
r5204 r5206 50 50 this->setName("Shell"); 51 51 52 // register the shell at the ShellBuffer 53 ShellBuffer::getInstance()->registerShell(this); 54 55 52 56 // Element2D and generals 53 57 this->setAbsCoor2D(3, -400); … … 71 75 } 72 76 73 Shell* Shell::singletonRef = NULL;74 75 77 /** 76 78 * standard deconstructor … … 85 87 // delete the inputLine 86 88 delete this->shellInput; 87 88 Shell::singletonRef = NULL; 89 ShellBuffer::getInstance()->unregisterShell(this); 89 90 } 90 91 … … 198 199 this->bufferText[i]->setText(NULL, true); 199 200 } 200 201 202 // BUFFER FLUSHING 201 // BUFFER FLUSHING 203 202 } 204 203 … … 240 239 } 241 240 242 243 244 241 /** 245 242 * listens for some event … … 322 319 } 323 320 324 325 326 321 // void Shell::testI (int i) 327 322 // { -
trunk/src/lib/shell/shell.h
r5204 r5206 36 36 37 37 public: 38 Shell(); 38 39 virtual ~Shell(); 39 /** @returns a Pointer to the only object of this Class */40 inline static Shell* getInstance() { if (!Shell::singletonRef) Shell::singletonRef = new Shell(); return Shell::singletonRef; };41 /** @returns true if this class is instanciated, false otherwise */42 inline static bool isInstanciated() { return (Shell::singletonRef == NULL)?false:true; };43 40 44 41 void activate(); … … 75 72 76 73 private: 77 Shell();78 static Shell* singletonRef; //!< The singleton-reference to the only memeber of this class.79 74 80 75 // GENERAL -
trunk/src/lib/shell/shell_buffer.cc
r5183 r5206 33 33 { 34 34 ShellBuffer::singletonRef = this; 35 this->shell = NULL; 35 36 36 37 this->lineCount = 0; … … 50 51 ShellBuffer::~ShellBuffer () 51 52 { 52 if ( Shell::isInstanciated())53 delete Shell::getInstance();53 if (this->shell != NULL) 54 delete this->shell; 54 55 55 56 this->flushBuffers(); … … 58 59 59 60 ShellBuffer::singletonRef = NULL; 61 } 62 63 /** 64 * registers the Shell to the Buffer 65 * @param shell the Shell to register. 66 */ 67 void ShellBuffer::registerShell(Shell* shell) 68 { 69 if (this->shell == NULL) 70 this->shell = shell; 71 else 72 PRINTF(1)("already registered a Shell to the ShellBuffer\n"); 73 } 74 75 /** 76 * unregisters the Shell from the Buffer 77 * @param shell the Shell to unregister. 78 */ 79 void ShellBuffer::unregisterShell(Shell* shell) 80 { 81 if (this->shell == shell) 82 this->shell = NULL; 83 else 84 PRINTF(1)("cannot unregister shell, because it is not registered to the ShellBuffer\n"); 60 85 } 61 86 … … 150 175 this->lineCount++; 151 176 this->buffer->add(addLine); 152 if ( Shell::isInstanciated() && Shell::getInstance()->isActive())153 Shell::getInstance()->printToDisplayBuffer(addLine);177 if (likely (this->shell != NULL) && unlikely (this->shell->isActive())) 178 this->shell->printToDisplayBuffer(addLine); 154 179 155 180 if (this->buffer->getSize() > this->bufferSize) -
trunk/src/lib/shell/shell_buffer.h
r5177 r5206 12 12 13 13 // FORWARD DECLARATION 14 class Shell; 14 15 template<class T> class tList; 15 16 template<class T> class tIterator; … … 27 28 /** @returns true if this class is instanciated, false otherwise */ 28 29 inline static bool isInstanciated() { return (ShellBuffer::singletonRef == NULL)?false:true; }; 30 31 void registerShell(Shell* shell); 32 void unregisterShell(Shell* shell); 29 33 30 34 // BUFFER // … … 54 58 tIterator<char>* bufferIterator; //!< An iterator for the Shells main buffer. 55 59 60 Shell* shell; //!< the Registered Shell. 56 61 char bufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER for fast writing 57 62 char keepBufferArray[SHELL_BUFFER_SIZE]; //!< a BUFFER to have multi-non-newLine commands be copied into the shell.
Note: See TracChangeset
for help on using the changeset viewer.