예제 #1
0
            ostream& OnEnteringPolygon::operator<<(ostream &out) const {
                // Serializer super class.
                StartType::operator<<(out);

                SerializationFactory& sf=SerializationFactory::getInstance();

                core::SharedPointer<Serializer> s = sf.getSerializer(out);

                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL2('i', 'd') >::RESULT,
                        getID());

                // Write number of vertices.
                uint32_t numberOfVertices = static_cast<uint32_t>(m_listOfVertices.size());
                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL8('n', 'u', 'm', 'v', 'e', 'r', 't', 's') >::RESULT,
                        numberOfVertices);

                // Write actual vertices to stringstream.
                stringstream sstr;
                for (uint32_t i = 0; i < numberOfVertices; i++) {
                    sstr << m_listOfVertices.at(i);
                }

                // Write string of vertices.
                if (numberOfVertices > 0) {
                    s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL8('v', 'e', 'r', 't', 'i', 'c', 'e', 's') >::RESULT,
                            sstr.str());
                }

                return out;
            }
예제 #2
0
파일: Road.cpp 프로젝트: tomkek/projects
            ostream& Road::operator<<(ostream &out) const {
                SerializationFactory sf;

                Serializer &s = sf.getSerializer(out);

                s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL2('i', 'd') >::RESULT,
                        getID());

                s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL4('n', 'a', 'm', 'e') >::RESULT,
                        getName());

                uint32_t numberOfLanes = static_cast<uint32_t>(m_listOfLanes.size());
                s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL8('n', 'u', 'm', 'l', 'a', 'n', 'e', 's') >::RESULT,
                        numberOfLanes);

                // Write lanes to stringstream.
                stringstream sstr;
                for (uint32_t i = 0; i < numberOfLanes; i++) {
                    // Write data to stringstream.
                    sstr << m_listOfLanes.at(i);
                }

                // Write lanes.
                if (numberOfLanes > 0) {
                    s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL5('l', 'a', 'n', 'e', 's') >::RESULT,
                            sstr.str());
                }

                return out;
            }
예제 #3
0
            ostream& IDVertex3::operator<<(ostream &out) const {
                // Serializer super class.
                Vertex3::operator<<(out);

                SerializationFactory& sf=SerializationFactory::getInstance();

                core::SharedPointer<Serializer> s = sf.getSerializer(out);

                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL2('i', 'd') >::RESULT,
                        getID());

                return out;
            }
예제 #4
0
            ostream& OnMoving::operator<<(ostream &out) const {
                // Serializer super class.
                StartType::operator<<(out);

                SerializationFactory& sf=SerializationFactory::getInstance();

                std::shared_ptr<Serializer> s = sf.getSerializer(out);

                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL2('i', 'd') >::RESULT,
                        getIdentifier());

                return out;
            }
예제 #5
0
            ostream& Layer::operator<<(ostream &out) const {
                SerializationFactory sf;

                Serializer &s = sf.getSerializer(out);

                s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL4('n', 'a', 'm', 'e') >::RESULT,
                        getName());

                s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL2('i', 'd') >::RESULT,
                        getID());

                s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL6('h', 'e', 'i', 'g', 'h', 't') >::RESULT,
                        getHeight());

                uint32_t numberOfRoads = static_cast<uint32_t>(m_listOfRoads.size());
                s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL8('n', 'u', 'm', 'r', 'o', 'a', 'd', 's') >::RESULT,
                        numberOfRoads);

                // Write roads to stringstream.
                stringstream sstr;
                for (uint32_t i = 0; i < numberOfRoads; i++) {
                    // Write data to stringstream.
                    sstr << m_listOfRoads.at(i);
                }

                // Write roads.
                if (numberOfRoads > 0) {
                    s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL5('r', 'o', 'a', 'd', 's') >::RESULT,
                            sstr.str());
                }

                uint32_t numberOfZones = static_cast<uint32_t>(m_listOfZones.size());
                s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL8('n', 'u', 'm', 'z', 'o', 'n', 'e', 's') >::RESULT,
                        numberOfZones);

                // Write zones to stringstream.
                sstr.str("");
                for (uint32_t i = 0; i < numberOfZones; i++) {
                    // Write data to stringstream.
                    sstr << m_listOfZones.at(i);
                }

                // Write zones.
                if (numberOfZones > 0) {
                    s.write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL5('z', 'o', 'n', 'e', 's') >::RESULT,
                            sstr.str());
                }

                return out;
            }
예제 #6
0
            ostream& Zone::operator<<(ostream &out) const {
                SerializationFactory& sf=SerializationFactory::getInstance();

                core::SharedPointer<Serializer> s = sf.getSerializer(out);

                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL2('i', 'd') >::RESULT,
                        getID());

                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL4('n', 'a', 'm', 'e') >::RESULT,
                        getName());

                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL8('p', 'e', 'r', 'i', 'm', 't', 'e', 'r') >::RESULT,
                        getPerimeter());

                uint32_t numberOfConnectors = static_cast<uint32_t>(m_listOfConnectors.size());
                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL8('n', 'u', 'm', 'c', 'o', 'n', 'n', 's') >::RESULT,
                        numberOfConnectors);

                // Write connectors to stringstream.
                stringstream sstr;
                for (uint32_t i = 0; i < numberOfConnectors; i++) {
                    // Write data to stringstream.
                    sstr << m_listOfConnectors.at(i);
                }

                // Write connectors.
                if (numberOfConnectors > 0) {
                    s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL5('c', 'o', 'n', 'n', 's') >::RESULT,
                            sstr.str());
                }

                uint32_t numberOfSpots = static_cast<uint32_t>(m_listOfSpots.size());
                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL8('n', 'u', 'm', 's', 'p', 'o', 't', 's') >::RESULT,
                        numberOfSpots);

                // Write spots to stringstream.
                sstr.str("");
                for (uint32_t i = 0; i < numberOfSpots; i++) {
                    // Write data to stringstream.
                    sstr << m_listOfSpots.at(i);
                }

                // Write spots.
                if (numberOfSpots > 0) {
                    s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL5('s', 'p', 'o', 't', 's') >::RESULT,
                            sstr.str());
                }

                return out;
            }
예제 #7
0
            ostream& Object::operator<<(ostream &out) const {
                SerializationFactory& sf=SerializationFactory::getInstance();

                std::shared_ptr<Serializer> s = sf.getSerializer(out);

                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL4('n', 'a', 'm', 'e') >::RESULT,
                        m_name);

                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL2('i', 'd') >::RESULT,
                        m_identifier);

                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL8('h', 'a', 's', 's', 'h', 'a', 'p', 'e') >::RESULT,
                        (m_shape != NULL));

                if (m_shape != NULL) {
                    // Write data to stringstream.
                    stringstream sstr;
                    sstr << static_cast<uint32_t>(m_shape->getType())
                    << *m_shape;

                    s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL5('s', 'h', 'a', 'p', 'e') >::RESULT,
                            sstr.str());
                }

                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL4('r', 'o', 't', 'z') >::RESULT,
                        m_rotationZ);

                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL8('h', 'a', 's', 'b', 'e', 'h', 'a', 'v') >::RESULT,
                        (m_behavior != NULL));

                if (m_behavior != NULL) {
                    // Write data to stringstream.
                    stringstream sstr;
                    sstr << static_cast<uint32_t>(m_behavior->getType())
                    << *m_behavior;

                    s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL5('b', 'e', 'h', 'a', 'v') >::RESULT,
                            sstr.str());
                }
                return out;
            }
예제 #8
0
            ostream& Lane::operator<<(ostream &out) const {
                SerializationFactory& sf=SerializationFactory::getInstance();

                std::shared_ptr<Serializer> s = sf.getSerializer(out);

                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL2('i', 'd') >::RESULT,
                        getIdentifier());

                // Check if we have to serialize a lane model.
                bool hasLaneModel = (getLaneModel() != NULL);
                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL7('h', 'a', 's', 'l', 'a', 'm', 'd') >::RESULT,
                        hasLaneModel);

                if (hasLaneModel) {
                    s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL7('l', 'a', 'n', 'e', 'm', 'd', 'l') >::RESULT,
                            static_cast<uint32_t>(getLaneModel()->getType()));

                    s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL5('m', 'o', 'd', 'e', 'l') >::RESULT,
                            *getLaneModel());
                }

                return out;
            }
예제 #9
0
                // Serializer super class.
                Vertex3::operator<<(out);

                SerializationFactory& sf=SerializationFactory::getInstance();

                core::SharedPointer<Serializer> s = sf.getSerializer(out);

                s->write(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL2('i', 'd') >::RESULT,
                        getID());

                return out;
            }

            istream& IDVertex3::operator>>(istream &in) {
                // Deserializer super class.
                Vertex3::operator>>(in);

                SerializationFactory& sf=SerializationFactory::getInstance();

                core::SharedPointer<Deserializer> d = sf.getDeserializer(in);

                d->read(CRC32 < OPENDAVINCI_CORE_STRINGLITERAL2('i', 'd') >::RESULT,
                       m_id);

                return in;
            }

        }
    }
} // hesperia::data::scenario