// #include "jptr.h" template tType* clJPTR::ptr() const { ldebug(cout<<"MEMBER type*"< void clJPTR< tType >::operator=( tType* pMem ) { ldebug(cout<<"MEMBER operator=pMemory"< void clJPTR< tType >::operator=( const clJPTR& oOther ) { ldebug(cout<<"MEMBER operator=Java Pointer"< tType* clJPTR< tType >::operator->() const { ldebug(cout<<"MEMBER operator ->"< tType* clJPTR< tType >::clone() const { ldebug( cout<<"MEMBER clone"< void clJPTR< tType >::add( tType* pMem ) { ldebug(cout<<"MEMBER add"< void clJPTR< tType >::remove() { ldebug(cout<<"MEMBER remove"<= 0) && "Map value is negative!" ); // If 0 then we have just deleted our last pointer if ( _oMap[_pKey] == 0 ) { ldebug( cout<<"DELETEING MEMORY: ",2 ); assert( _pKey && "Major bug, this should never be NULL" ); // Remove Memory delete _pKey; // Remove Key Entry _oMap.erase( _pKey ); } // undefine key _pKey = NULL; // List table of entries ldebug( print(2), 2 ); } template< class tType > void clJPTR< tType >::print(int level) { assert( (level > -1) && "Expecting a non-negative level!" ); clMap::const_iterator iWalk; char cBuff[30] = { 0 }; char cTabs[20] = { 0 }; // Fill fillers memset( cBuff, '-', sizeof( cBuff ) -1 ); memset( cTabs, '\t', min( level, (int) sizeof( cTabs ) - 1) ); // add a new line cout << endl; // Title of table cout << cTabs << "Ptr -> Reference Count" << endl; cout << cTabs << cBuff << endl; // Elements of Table for( iWalk = _oMap.begin(); iWalk != _oMap.end(); iWalk ++ ) { cout << cTabs << (*iWalk).first << " -> " << (*iWalk).second << endl; } // Trailer of table cout << cTabs << cBuff << endl; } /* The reason this is private is so the you the programmer are not tempted to write something like clJPTR< xcl > oNew; because this pointer will not have an object to after it's constructor and a little too dangerous. */ template < class tType > clJPTR< tType >::clJPTR() { ldebug(cout<<"DEFAULT Constructor"< clJPTR::clJPTR( tType* pMem ) { ldebug(cout<<"MEM Constructor"< clJPTR::clJPTR(const clJPTR& oThat) { ldebug(cout<<"COPY Constructor"< clJPTR::~clJPTR() { ldebug(cout<<"Destructor"< void clJPTR::OutOfMemory() { ldebug(cout << "ERROR: Out of Memory" << endl, 1 ); assert( 0 && "Out of Memory!" ); } // Wierd but true, global variable declaration for this // class. // template clJPTR::clMap clJPTR::_oMap;