本文整理汇总了C++中Link::GetObject方法的典型用法代码示例。如果您正苦于以下问题:C++ Link::GetObject方法的具体用法?C++ Link::GetObject怎么用?C++ Link::GetObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Link
的用法示例。
在下文中一共展示了Link::GetObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFromMap
//----------------------------------------------------------------------------
Object* Stream::GetFromMap (Object* pkLinkID)
{
map<Object*,void*>::iterator kOIter = m_kMap.find(pkLinkID);
if ( kOIter != m_kMap.end() )
{
Link* pkLink = (Link*) kOIter->second;
return pkLink->GetObject();
}
else
{
return NULL;
}
}
示例2: Load
//----------------------------------------------------------------------------
// memory streaming
//----------------------------------------------------------------------------
bool Stream::Load (char* acBuffer, int iSize, int iNext)
{
assert( m_kMap.empty() && m_kOrdered.empty() );
// clear out all previous top level objects
RemoveAll();
// Memory blocks are always current version. The file loader calls
// Stream::Load, but with iNext = Version::LENGTH > 0, so iNext == 0
// means this is a memory block load. This means the caller of
// Stream::Load for a memory block should *not* set iNext.
if ( iNext == 0 )
m_kVersion = Version(Version::MAJOR,Version::MINOR);
// initialize the internal Stream buffer
m_iBufferSize = iSize;
m_iBufferNext = iNext;
m_acBuffer = acBuffer;
// load list of unique objects
Object* pkObject;
while ( m_iBufferNext < m_iBufferSize )
{
// read "Top Level" or RTTI name
char* acString;
Read(acString);
bool bTopLevel = ( strcmp(acString,ms_acTopLevel) == 0 );
if ( bTopLevel )
{
// read RTTI name
delete[] acString;
Read(acString);
}
// get the factory function for the type of object about to be read
map<string,FactoryFunction>::iterator kFIter =
Object::ms_pkFactory->find(string(acString));
assert( kFIter != Object::ms_pkFactory->end() );
if ( kFIter == Object::ms_pkFactory->end() )
{
// cannot find factory function
delete[] acString;
return false;
}
// load the object
FactoryFunction oFactory = kFIter->second;
pkObject = oFactory(*this);
// keep track of all top level objects for application use
if ( bTopLevel )
Insert(pkObject);
delete[] acString;
}
// link the objects
Link* pkLink;
map<Object*,void*>::iterator kOIter;
for (kOIter = m_kMap.begin(); kOIter != m_kMap.end(); kOIter++)
{
pkLink = (Link*)kOIter->second;
pkObject = pkLink->GetObject();
pkObject->Link(*this,pkLink);
}
// delete the stream link records
for (kOIter = m_kMap.begin(); kOIter != m_kMap.end(); kOIter++)
{
pkLink = (Link*)kOIter->second;
delete pkLink;
}
m_kMap.clear();
m_kOrdered.clear();
return true;
}