当前位置: 首页>>代码示例>>C++>>正文


C++ ActorPtr::isValid方法代码示例

本文整理汇总了C++中ActorPtr::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ ActorPtr::isValid方法的具体用法?C++ ActorPtr::isValid怎么用?C++ ActorPtr::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActorPtr的用法示例。


在下文中一共展示了ActorPtr::isValid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DeserializeActor

        void ActorSerializer::DeserializeActor(std::istream& stream, std::vector<ActorPtr>& actors)
        {
            if (!stream)
                throw Commons::IOException("Stream is not opened");

            ActorPtr curActor;
            int32_t curLevel = 0;

            BigEndianStreamReader reader(stream);

            FileHeaderChunk fileHeader;
            ChunkHeader header;
            while (!reader.isEOF())
            {
                header.read(reader);

                uint32_t lastOffset = reader.tell();

                if (header.getMagic() == FileHeaderChunk::MAGIC)
                {
                    fileHeader.read(reader);                    
                }
                else if (header.getMagic() == ActorNameChunk::MAGIC)
                {
                    curActor = ActorPtr(new Actor());
                    assert(curActor.get());
                    curActor->m_header.read(reader);

                    ++curLevel;
                    printf("%d: %s\n", curLevel, curActor->m_header.m_name.data());
                }
                else if (header.getMagic() == ActorMatrixChunk::MAGIC)
                {
                    assert(curActor.get());
                    curActor->m_matrix.read(reader);
                }
                else if (header.getMagic() == ActorPushChunk::MAGIC)
                {
                    assert(curActor.get());
                    // TODO: push
                }
                else if (header.getMagic() == ActorPopChunk::MAGIC)
                {
                    assert(curActor.get());
                    // TODO: pop
                    --curLevel;
                }
                else if (header.getMagic() == ActorMaterialChunk::MAGIC)
                {
                    assert(curActor.get());
                    curActor->m_materials.read(reader);
                }
                else if (header.getMagic() == ActorModelChunk::MAGIC)
                {
                    assert(curActor.get());
                    curActor->m_models.read(reader);
                }
                else if (header.getMagic() == ActorEmptyChunk::MAGIC)
                {
                    assert(curActor.get());
                    curActor->m_empty.read(reader);
                }
                else if (header.getMagic() == ActorBBoxChunk::MAGIC)
                {
                    assert(curActor.get());
                    curActor->m_bbox.read(reader);
                }
                else if (header.isNULL())
                {
                    if (!curActor.get() || !curActor->isValid())
                        throw Commons::SerializationException("Actor object is incorrect");
                    actors.push_back(curActor);
                    curActor.reset();
                }
                else
                {
                    std::stringstream ss;
                    ss << "Unknown chunk: " << header.getMagic() << " at " << reader.tell();
                    throw Commons::SerializationException(ss.str());
                }

                uint32_t redSize = reader.tell() - lastOffset;
                if (redSize != header.getSize())
                {
                    std::stringstream ss;
                    ss << "Incorrect chunk size red: required: " << header.getSize() << " current " << redSize;
                    //throw SerializationException(ss.str()); // TODO: warning
                    //printf("%s\n", ss.str().data());
                }
            }
        }
开发者ID:bitlinker,项目名称:OpenCarma,代码行数:91,代码来源:ActorSerializer.cpp


注:本文中的ActorPtr::isValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。