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

panda/src/express/tokenBoard.h

Go to the documentation of this file.
00001 // Filename: tokenBoard.h
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 #ifndef TOKENBOARD_H
00020 #define TOKENBOARD_H
00021 
00022 #include "pandabase.h"
00023 #include "plist.h"
00024 #include "circBuffer.h"
00025 #include "pointerTo.h"
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //      Struct : TokenMatch
00029 // Description : This is an STL predicate function object that is used
00030 //               to find a particular id in a list of token pointers.
00031 //               It returns true when the token's id matches the
00032 //               numeric id supplied to the constructor.
00033 ////////////////////////////////////////////////////////////////////
00034 template<class TokenType>
00035 class TokenMatch {
00036 public:
00037   TokenMatch(int id) {
00038     _want_id = id;
00039   }
00040   bool operator()(PT(TokenType) tok) const {
00041     return (int)tok->_id == _want_id;
00042   }
00043   int _want_id;
00044 };
00045 
00046 const int MAX_TOKENBOARD_REQUESTS = 100;
00047 
00048 ////////////////////////////////////////////////////////////////////
00049 //       Class : TokenBoard
00050 // Description :
00051 ////////////////////////////////////////////////////////////////////
00052 template<class TokenType>
00053 class TokenBoard {
00054 public:
00055   bool is_done_token(int id);
00056   PT(TokenType) get_done_token(int id);
00057 
00058   // waiting holds the list of requests sent to the DBASE process, not
00059   // yet handled.
00060   CircBuffer<PT(TokenType), MAX_TOKENBOARD_REQUESTS> _waiting;
00061 
00062   // done holds the list of requests handled by the DBASE process, but
00063   // not yet discovered by APP.  Probably this queue will only have
00064   // one item at a time on it.
00065   CircBuffer<PT(TokenType), MAX_TOKENBOARD_REQUESTS> _done;
00066 
00067   // really_done holds the requests extracted from done.  These are
00068   // extracted into the local list so we can safely search for and
00069   // remove a particular token from the middle of the list (we can
00070   // only remove from the head of a circular buffer).
00071   plist< PT(TokenType) > _really_done;
00072 };
00073 
00074 #include "tokenBoard.I"
00075 
00076 #endif

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