Subversion Repositories gelsvn

Rev

Rev 56 | Rev 129 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 56 Rev 89
Line 13... Line 13...
13
 
13
 
14
	typedef unsigned char FlagByte;
14
	typedef unsigned char FlagByte;
15
	const FlagByte REMOVE_WHEN_UNUSED = 0x01;
15
	const FlagByte REMOVE_WHEN_UNUSED = 0x01;
16
	const FlagByte STATIC_RESOURCE    = 0x02;
16
	const FlagByte STATIC_RESOURCE    = 0x02;
17
 
17
 
18
	/** This class template represents a resource record. There is a pointer to 
18
	/** \brief This class template represents a resource record. 
-
 
19
 
-
 
20
	    There is a pointer to 
19
			the actual resource (of type RES) and a usage counter which should never
21
			the actual resource (of type RES) and a usage counter which should never
20
			be less than 0. */
22
			be less than 0. */
21
	template<class RES>
23
	template<class RES>
22
	class ResourceRecord
24
	class ResourceRecord
23
	{
25
	{
Line 109... Line 111...
109
 
111
 
110
 
112
 
111
	template<class RES> class ResourceManager;
113
	template<class RES> class ResourceManager;
112
 
114
 
113
 
115
 
-
 
116
	/** \brief Template for a pointer to a reference counted resource.
-
 
117
 
114
	/** The ResourcePtr class template is a template for a reference
118
      The ResourcePtr class template is a template for a reference
115
			counted resource pointer. It is a smart pointer that actually points
119
			counted resource pointer. It is a smart pointer that actually points
116
			to a ResourceRecord and not to the actual resource. Since the record
120
			to a ResourceRecord and not to the actual resource. Since the record
117
			contains a reference count, we can increase the reference count when
121
			contains a reference count, we can increase the reference count when
118
			the pointer is copied and decrease it in the destructor. Only the
122
			the pointer is copied and decrease it in the destructor. Only the
119
			ResourceManager can create ResourcePtr's directly from a raw
123
			ResourceManager can create ResourcePtr's directly from a raw
Line 218... Line 222...
218
				flag is set, the resource record is removed from the manager */
222
				flag is set, the resource record is removed from the manager */
219
		void remove_when_unused() {	rr->remove_when_unused(); }
223
		void remove_when_unused() {	rr->remove_when_unused(); }
220
	};
224
	};
221
 
225
 
222
 
226
 
-
 
227
	/** \brief Resource manager class.
-
 
228
 
223
	/** The ResourceManager is a singleton, and it uses Scott Meyers construct
229
      The ResourceManager is a singleton, and it uses Scott Meyers construct
224
			on first use idiom, i.e. the static function get_instance() will
230
			on first use idiom, i.e. the static function get_instance() will
225
			construct it when first called. There may be a problem with this
231
			construct it when first called. There may be a problem with this
226
			idion if resources depend on each other. However, that is only
232
			idion if resources depend on each other. However, that is only
227
			when the program shuts down.  See modern C++ design by
233
			when the program shuts down.  See modern C++ design by
228
			Alexandrescu for more information.
234
			Alexandrescu for more information.