Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Examples

MazeFactory.hpp

00001 #if !defined(__MAZEFACTORY_HPP) 00002 #define __MAZEFACTORY_HPP 00003 00004 /* 00005 CoreLinux++ 00006 Copyright (C) 2000 CoreLinux Consortium 00007 00008 The CoreLinux++ Library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Library General Public License as 00010 published by the Free Software Foundation; either version 2 of the 00011 License, or (at your option) any later version. 00012 00013 The CoreLinux++ Library Library is distributed in the hope that it will 00014 be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Library General Public License for more details. 00017 00018 You should have received a copy of the GNU Library General Public 00019 License along with the GNU C Library; see the file COPYING.LIB. If not, 00020 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00021 Boston, MA 02111-1307, USA. 00022 */ 00023 00024 00025 #if !defined(__COMMON_HPP) 00026 #include <Common.hpp> 00027 #endif 00028 00029 #if !defined(__ABSTRACTFACTORY_HPP) 00030 #include <AbstractFactory.hpp> 00031 #endif 00032 00033 #if !defined(__ALLOCATOR_HPP) 00034 #include <Allocator.hpp> 00035 #endif 00036 00037 #if !defined(__MAP_HPP) 00038 #include <Map.hpp> 00039 #endif 00040 00041 #if !defined(__NAMEIDENTIFIER_HPP) 00042 #include <NameIdentifier.hpp> 00043 #endif 00044 00045 #if !defined(__DOOR_HPP) 00046 #include <Door.hpp> 00047 #endif 00048 00049 #if !defined(__ROOM_HPP) 00050 #include <Room.hpp> 00051 #endif 00052 00053 #if !defined(__WALL_HPP) 00054 #include <Wall.hpp> 00055 #endif 00056 00057 00058 // 00059 // We use a map for storing our allocators. We could have fire-walled this 00060 // as well. 00061 // 00062 00063 CORELINUX_MAP( 00064 NameIdentifier, 00065 CORELINUX(AllocatorPtr), 00066 less<NameIdentifier>, 00067 NamedAllocators 00068 ); 00069 00070 00080 DECLARE_CLASS( MazeFactory ); 00081 00082 class MazeFactory : protected CORELINUX(AbstractFactory<NameIdentifier>) 00083 { 00084 public: 00085 00086 // 00087 // Constructors and destructor 00088 // 00089 00091 00092 MazeFactory( void ); 00093 00095 00096 MazeFactory( MazeFactoryCref ); 00097 00099 00100 virtual ~MazeFactory( void ); 00101 00102 // 00103 // Operator overloads 00104 // 00105 00107 00108 MazeFactoryRef operator=( MazeFactoryCref ) 00109 throw(CORELINUX(Exception)); 00110 00112 00113 bool operator==( MazeFactoryCref ) const; 00114 00115 // 00116 // Accessors 00117 // 00118 00120 00121 CORELINUX(Count) getAllocatorCount( void ) const; 00122 00124 00125 CORELINUX(Count) getTotalAllocates( void ) const; 00126 00128 00129 CORELINUX(Count) getTotalDeallocates( void ) const; 00130 00131 // 00132 // Factory methods 00133 // 00134 00136 00137 virtual RoomPtr createRoom( RoomNumberCref ) const 00138 throw(CORELINUX(AllocatorNotFoundException)); 00139 00141 00142 virtual WallPtr createWall( void ) const 00143 throw(CORELINUX(AllocatorNotFoundException)); 00144 00146 00147 virtual DoorPtr createDoor( RoomPtr, RoomPtr ) const 00148 throw(CORELINUX(AllocatorNotFoundException)); 00149 00151 00152 virtual void destroyRoom( RoomPtr ) const 00153 throw(CORELINUX(AllocatorNotFoundException)); 00154 00156 00157 virtual void destroyWall( WallPtr ) const 00158 throw(CORELINUX(AllocatorNotFoundException)); 00159 00161 00162 virtual void destroyDoor( DoorPtr ) const 00163 throw(CORELINUX(AllocatorNotFoundException)); 00164 00165 00166 protected: 00167 00168 // 00169 // Accessors overriden from AbstractFactory 00170 // 00171 00173 00174 virtual CORELINUX(Count) getCreateCount( void ) const; 00175 00177 00178 virtual CORELINUX(Count) getDestroyCount( void ) const; 00179 00181 00182 virtual CORELINUX(AllocatorPtr) getAllocator( NameIdentifier ) const 00183 throw(CORELINUX(AllocatorNotFoundException)); 00184 00185 // 00186 // Mutators overriden from AbstractFactory 00187 // 00188 00190 00191 virtual void addAllocator( NameIdentifier, CORELINUX(AllocatorPtr) ) 00192 throw(CORELINUX(AllocatorAlreadyExistsException)); 00193 00196 00197 virtual CORELINUX(AllocatorPtr) removeAllocator( NameIdentifier ) 00198 throw(CORELINUX(AllocatorNotFoundException)); 00199 // 00200 // Overides Iterator factory methods from AbstractFactory 00201 // 00208 virtual CORELINUX(Iterator<corelinux::AllocatorPtr>)* createIterator( void ) const; 00209 00215 virtual void destroyIterator( CORELINUX(Iterator<corelinux::AllocatorPtr>)* ) const; 00216 00224 virtual corelinux::AssociativeIterator<NameIdentifier,corelinux::AllocatorPtr>* 00225 createAssociativeIterator( void ) const; 00226 00233 virtual void destroyAssociativeIterator 00234 ( 00235 corelinux::AssociativeIterator<NameIdentifier,corelinux::AllocatorPtr>* 00236 ) const; 00237 00238 00239 protected: 00240 00242 00243 void flushAllocators( void ); 00244 00245 private: 00246 00247 NamedAllocators theAllocators; 00248 }; 00249 00250 #endif // if !defined(__MAZEFACTORY_HPP) 00251 00252 /* 00253 Common rcs information do not modify 00254 $Author: prudhomm $ 00255 $Revision: 1.2 $ 00256 $Date: 2000/08/31 22:47:56 $ 00257 $Locker: $ 00258 */ 00259 00260

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium