Game Development Reference
In-Depth Information
std::string name(pData->Value());
StrongActorComponentPtr pComponent;
auto findIt = m_actorComponentCreators.find(name);
if (findIt != m_actorComponentCreators.end())
{
ActorComponentCreator creator = findIt->second;
pComponent.reset(creator());
}
else
{
GCC_ERROR(
Couldn
'
t find ActorComponent named
+ name);
return StrongActorComponentPtr(); // fail
}
// initialize the component if we found one
if (pComponent)
{
if (!pComponent->Init(pData))
{
GCC_ERROR(“Component failed to initialize: ” + name);
return StrongActorComponentPtr();
}
}
// pComponent will be NULL if the component wasn
t
// necessarily an error since you might have a custom CreateComponent()
// function in a subclass.
return pComponent;
'
t found. This isn
'
}
C++0x/C++ 11 Redefines the auto Keyword
What is the auto keyword doing in that function? There
s a new standard
being published called C++0x, or C++ 11. This new standard adds a huge
amount of really cool features to the C++ language, some of which were
covered in Chapter 3. If you have Visual Studio 2010, you can take
advantage of a few of them.
'
One of these features is the newly overloaded auto keyword. The original
usage of this keyword was to declare the variable in the automatic storage
class. In other words, make the variable behave normally. This made it the
single most useless (and redundant) keyword in the C++ language. In C++0x,
the auto keyword now defines a variable whose type can be deduced at
compile time. In the above code, I use it to declare an iterator so that if the
 
Search WWH ::




Custom Search