<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Gem: A Generic Handle-Based Resource Manager</title>
	<atom:link href="http://scottbilas.com/publications/gem-resmgr/feed/" rel="self" type="application/rss+xml" />
	<link>http://scottbilas.com</link>
	<description>Take what you want, and leave the rest (just like your salad bar).</description>
	<lastBuildDate>Mon, 06 Feb 2012 03:15:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: John</title>
		<link>http://scottbilas.com/publications/gem-resmgr/#comment-1036</link>
		<dc:creator>John</dc:creator>
		<pubDate>Mon, 26 Sep 2011 09:02:31 +0000</pubDate>
		<guid isPermaLink="false">http://scottbilas.com/?page_id=431#comment-1036</guid>
		<description>Scott,

Just wanted to say thanks for an excellent set of articles on your blog here. It is one thing to try and learn these things on your own, but nothing can replace learning by reading great code. 

It is refreshing to see such a wealth of source code associated with an article! Was quite a fun exercise to refactor your design (including the full package builder/manager) into my current engine using boost::paths and memory mapped files! 

Thanks again mate,
John</description>
		<content:encoded><![CDATA[<p>Scott,</p>
<p>Just wanted to say thanks for an excellent set of articles on your blog here. It is one thing to try and learn these things on your own, but nothing can replace learning by reading great code. </p>
<p>It is refreshing to see such a wealth of source code associated with an article! Was quite a fun exercise to refactor your design (including the full package builder/manager) into my current engine using boost::paths and memory mapped files! </p>
<p>Thanks again mate,<br />
John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Clark</title>
		<link>http://scottbilas.com/publications/gem-resmgr/#comment-865</link>
		<dc:creator>Chris Clark</dc:creator>
		<pubDate>Wed, 13 Apr 2011 04:58:32 +0000</pubDate>
		<guid isPermaLink="false">http://scottbilas.com/?page_id=431#comment-865</guid>
		<description>It works! Thank you very much for your help!</description>
		<content:encoded><![CDATA[<p>It works! Thank you very much for your help!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Clark</title>
		<link>http://scottbilas.com/publications/gem-resmgr/#comment-864</link>
		<dc:creator>Chris Clark</dc:creator>
		<pubDate>Wed, 13 Apr 2011 04:53:24 +0000</pubDate>
		<guid isPermaLink="false">http://scottbilas.com/?page_id=431#comment-864</guid>
		<description>Thank you, I will give it a try and let you know how it goes.</description>
		<content:encoded><![CDATA[<p>Thank you, I will give it a try and let you know how it goes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://scottbilas.com/publications/gem-resmgr/#comment-863</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Wed, 13 Apr 2011 04:48:54 +0000</pubDate>
		<guid isPermaLink="false">http://scottbilas.com/?page_id=431#comment-863</guid>
		<description>This article was written under a version of Visual C++ that used an STL where iterators on vectors were simply pointers. In more modern versions of the STL, like the one you have, iterators are usually wrapped up into classes. The error you&#039;re getting is because the iterator does not auto convert to the pointer again.

To fix, just take the address of the dereferenced iterator. Something like this:

[code]
return &amp;*(m_UserData.begin() + index);
[/code]</description>
		<content:encoded><![CDATA[<p>This article was written under a version of Visual C++ that used an STL where iterators on vectors were simply pointers. In more modern versions of the STL, like the one you have, iterators are usually wrapped up into classes. The error you&#8217;re getting is because the iterator does not auto convert to the pointer again.</p>
<p>To fix, just take the address of the dereferenced iterator. Something like this:</p>
<pre class="brush: plain;">
return &amp;*(m_UserData.begin() + index);
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Clark</title>
		<link>http://scottbilas.com/publications/gem-resmgr/#comment-857</link>
		<dc:creator>Chris Clark</dc:creator>
		<pubDate>Mon, 11 Apr 2011 04:25:33 +0000</pubDate>
		<guid isPermaLink="false">http://scottbilas.com/?page_id=431#comment-857</guid>
		<description>Scott,
I am working on my first game, finally nailed the idea for the game play. I am working on the subsystems now and came across your article in Game Programming Gems 1 titled “A Generic Handle-Base Resource Manager”. I was very intrigued by the article and copied the 3 files given into my project. I went through the code and while I understand most of it, I am still a bit foggy on templates and typenames. I added my own FileMgr based on the handle and HandleMgr headers and the Texture Manager implementation you provided. I am getting a compile error as it seems the HandleMgr can’t return from Vector (std::_Vector_iterator) to TextureMgr::Texture *. The code for the HandleMgr is given below. Please could you take a look and see how I can resolve this issue.

template
class HandleMgr
{
private:
// private types
typedef std::vector UserVec;
typedef std::vector MagicVec;
typedef std::vector FreeVec;

// private data
UserVec m_UserData; // data we&#039;re going to get to
MagicVec m_MagicNumbers; // corresponding magic numbers
FreeVec m_FreeSlots; // keeps track of free slots in the db

public:
// Lifetime.
HandleMgr( void ) { }
~HandleMgr( void ) { }

// Handle methods.
// acquisition
DATA* Acquire( HANDLE&amp; handle );
void Release( HANDLE handle );

// dereferencing
DATA* Dereference( HANDLE handle );
const DATA* Dereference( HANDLE handle ) const;

// other query
unsigned int GetUsedHandleCount( void ) const
{ return ( m_MagicNumbers.size() - m_FreeSlots.size() ); }
bool HasUsedHandles( void ) const
{ return ( !!GetUsedHandleCount() ); }
};

template
DATA* HandleMgr :: Acquire( HANDLE&amp; handle )
{
// if free list is empty, add a new one otherwise use first one found

unsigned int index;
if ( m_FreeSlots.empty() )
{
index = m_MagicNumbers.size();
handle.Init( index );
m_UserData.push_back( DATA() );
m_MagicNumbers.push_back( handle.GetMagic() );
}
else
{
index = m_FreeSlots.back();
handle.Init( index );
m_FreeSlots.pop_back();
m_MagicNumbers[ index ] = handle.GetMagic();
}
return ( m_UserData.begin() + index ); // error here (see below)
}

Compile ERROR Message:
(error C2440: ‘return’ : cannot convert from ’std::_Vector_iterator’ to ‘TextureMgr::Texture *’) –&gt; No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called while compiling class template member function ‘TextureMgr::Texture *HandleMgr::Acquire(HANDLE &amp;)’

Any help is greatly appreciated and please let me know if you need anything else.</description>
		<content:encoded><![CDATA[<p>Scott,<br />
I am working on my first game, finally nailed the idea for the game play. I am working on the subsystems now and came across your article in Game Programming Gems 1 titled “A Generic Handle-Base Resource Manager”. I was very intrigued by the article and copied the 3 files given into my project. I went through the code and while I understand most of it, I am still a bit foggy on templates and typenames. I added my own FileMgr based on the handle and HandleMgr headers and the Texture Manager implementation you provided. I am getting a compile error as it seems the HandleMgr can’t return from Vector (std::_Vector_iterator) to TextureMgr::Texture *. The code for the HandleMgr is given below. Please could you take a look and see how I can resolve this issue.</p>
<p>template<br />
class HandleMgr<br />
{<br />
private:<br />
// private types<br />
typedef std::vector UserVec;<br />
typedef std::vector MagicVec;<br />
typedef std::vector FreeVec;</p>
<p>// private data<br />
UserVec m_UserData; // data we&#8217;re going to get to<br />
MagicVec m_MagicNumbers; // corresponding magic numbers<br />
FreeVec m_FreeSlots; // keeps track of free slots in the db</p>
<p>public:<br />
// Lifetime.<br />
HandleMgr( void ) { }<br />
~HandleMgr( void ) { }</p>
<p>// Handle methods.<br />
// acquisition<br />
DATA* Acquire( HANDLE&amp; handle );<br />
void Release( HANDLE handle );</p>
<p>// dereferencing<br />
DATA* Dereference( HANDLE handle );<br />
const DATA* Dereference( HANDLE handle ) const;</p>
<p>// other query<br />
unsigned int GetUsedHandleCount( void ) const<br />
{ return ( m_MagicNumbers.size() &#8211; m_FreeSlots.size() ); }<br />
bool HasUsedHandles( void ) const<br />
{ return ( !!GetUsedHandleCount() ); }<br />
};</p>
<p>template<br />
DATA* HandleMgr :: Acquire( HANDLE&amp; handle )<br />
{<br />
// if free list is empty, add a new one otherwise use first one found</p>
<p>unsigned int index;<br />
if ( m_FreeSlots.empty() )<br />
{<br />
index = m_MagicNumbers.size();<br />
handle.Init( index );<br />
m_UserData.push_back( DATA() );<br />
m_MagicNumbers.push_back( handle.GetMagic() );<br />
}<br />
else<br />
{<br />
index = m_FreeSlots.back();<br />
handle.Init( index );<br />
m_FreeSlots.pop_back();<br />
m_MagicNumbers[ index ] = handle.GetMagic();<br />
}<br />
return ( m_UserData.begin() + index ); // error here (see below)<br />
}</p>
<p>Compile ERROR Message:<br />
(error C2440: ‘return’ : cannot convert from ’std::_Vector_iterator’ to ‘TextureMgr::Texture *’) –&gt; No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called while compiling class template member function ‘TextureMgr::Texture *HandleMgr::Acquire(HANDLE &amp;)’</p>
<p>Any help is greatly appreciated and please let me know if you need anything else.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

