Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/express/tokenBoard.I

Go to the documentation of this file.
00001 // Filename: tokenBoard.I
00002 // Created by:  mike (09Jan97)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 ////////////////////////////////////////////////////////////////////
00020 //     Function: TokenBoard::is_done_token()
00021 //       Access: Public
00022 //  Description: Returns true if the indicated token id is on the
00023 //               done queue, false otherwise.
00024 ////////////////////////////////////////////////////////////////////
00025 template<class TokenType>
00026 bool TokenBoard<TokenType>::
00027 is_done_token(int id) {
00028   // First, empty the done list, copying them to really_done.  We have
00029   // to do this since we can only examine tokens on the head of the
00030   // done list, and the token we're looking for might not be at the
00031   // head.
00032   while (!_done.empty()) {
00033     _really_done.push_back(_done.front());
00034     _done.pop_front();
00035   }
00036 
00037   // Now we can search really_done for our desired id.
00038   TYPENAME plist< PT(TokenType) >::iterator found;
00039   found = find_if(_really_done.begin(), _really_done.end(),
00040                   TokenMatch<TokenType>(id));
00041 
00042   return (found != _really_done.end());
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: TokenBoard::get_done_token
00047 //       Access: Public
00048 //  Description: Locates the token by the given id in the list of done
00049 //               tokens, removes it from the list, and returns its
00050 //               pointer (which should be deleted by the calling
00051 //               function).  Returns NULL if the token was not on the
00052 //               done list.
00053 ////////////////////////////////////////////////////////////////////
00054 template<class TokenType>
00055 PT(TokenType) TokenBoard<TokenType>::
00056 get_done_token(int id) {
00057   // First, empty the done list, copying them to really_done.  We have
00058   // to do this since we can only examine tokens on the head of the
00059   // done list, and the token we're looking for might not be at the
00060   // head.
00061   while (!_done.empty()) {
00062     _really_done.push_back(_done.front());
00063     _done.pop_front();
00064   }
00065 
00066   // Now we can search really_done for our desired id.
00067   TYPENAME plist< PT(TokenType) >::iterator found;
00068   found = find_if(_really_done.begin(), _really_done.end(),
00069                   TokenMatch<TokenType>(id));
00070 
00071   if (found == _really_done.end()) {
00072     return NULL;
00073   } else {
00074     PT(TokenType) tok = *found;
00075     _really_done.erase(found);
00076     return tok;
00077   }
00078 }

Generated on Fri May 2 00:38:42 2003 for Panda by doxygen1.3