#include <context.h>
Collaboration diagram for context::ContextStack:
Public Methods | |
void | push (Context &cont) |
Adds a Context to the end of the stack. | |
void | pop () |
Removes a Context from the end of the stack. | |
void | pop (Context &cx) |
Removes a Context from the end of the stack. | |
auto_ptr< vector< string > > | makeSVector () const |
Produces a vector of strings representing the current ContextStack. | |
Static Public Methods | |
ContextStack & | getInstanceOf () |
Static method to get a ContextStack. | |
void | print () |
Prints the current context. |
|
Static method to get a ContextStack.
|
|
Adds a Context to the end of the stack.
00092 { 00093 stack.push_back(&cont); 00094 } |
|
Removes a Context from the end of the stack.
00101 { 00102 stack.pop_back(); 00103 } |
|
Removes a Context from the end of the stack. Prints interesting errors if the wrong Context is removed
00113 { 00114 00115 if (stack.size()==0) 00116 { 00117 cout<<"Attempt to pop empty stack\n"; 00118 return; 00119 } 00120 if (&cx!=stack[stack.size()-1]) 00121 { 00122 cout <<"Attempt to pop wrong context:\n"; 00123 cout <<"\""<<cx.getDescription()<<"\" (cx) should be\n"; 00124 cout <<"\""<<stack[stack.size()-1]->getDescription()<<"\" (*stack["; 00125 cout <<stack.size()<<"])\n"; 00126 return; 00127 } 00128 pop(); 00129 } |
|
Produces a vector of strings representing the current ContextStack.
00137 { 00138 auto_ptr< vector<string> > myvector(new vector<string>); 00139 if (myvector.get()==NULL) return myvector; 00140 for (size_t i=0; i<stack.size(); ++i) 00141 { 00142 myvector->push_back(stack[i]->getDescription()); 00143 } 00144 00145 return myvector; 00146 } |
|
Prints the current context.
00153 { 00154 auto_ptr< vector<string> > cxv(getInstanceOf().makeSVector()); 00155 Context::print(*cxv); 00156 } |