예제 #1
0
파일: cache.cpp 프로젝트: MKLab-ITI/gnorasi
std::string Cache::getPropertyState() {
    // create temporary property map for serialization
    std::map<std::string, Property*> propertyMap;
    for (size_t i=0; i < properties_.size(); ++i) {
        Property* p = processor_->getProperty(properties_[i]);
        if(p)
            propertyMap[properties_[i]] = p;
    }

    // serialize properties
    XmlSerializer s;

    const bool usePointerContentSerialization = s.getUsePointerContentSerialization();
    s.setUsePointerContentSerialization(true);
    try {
        s.serialize("Properties", propertyMap, "Property", "name");
    }
    catch (SerializationException& e) {
        LWARNING(e.what());
    }
    s.setUsePointerContentSerialization(usePointerContentSerialization);

    std::stringstream stream;
    s.write(stream);
    return stream.str();
}
예제 #2
0
void Processor::serialize(XmlSerializer& s) const {
    // meta data
    metaDataContainer_.serialize(s);

    // misc settings
    s.serialize("name", id_);

    // serialize properties
    PropertyOwner::serialize(s);


    // ---
    // the following entities are static resources (i.e. already existing at this point)
    // that should therefore not be dynamically created by the serializer
    //
    const bool usePointerContentSerialization = s.getUsePointerContentSerialization();
    s.setUsePointerContentSerialization(true);

    // serialize inports using a temporary map
    std::map<std::string, Port*> inportMap;
    for (std::vector<Port*>::const_iterator it = inports_.begin(); it != inports_.end(); ++it)
        inportMap[(*it)->getID()] = *it;
    try {
        s.serialize("Inports", inportMap, "Port", "name");
    }
    catch (SerializationException& e) {
        LWARNING(e.what());
    }

    // serialize outports using a temporary map
    std::map<std::string, Port*> outportMap;
    for (std::vector<Port*>::const_iterator it = outports_.begin(); it != outports_.end(); ++it)
        outportMap[(*it)->getID()] = *it;
    try {
        s.serialize("Outports", outportMap, "Port", "name");
    }
    catch (SerializationException& e) {
        LWARNING(e.what());
    }

    // serialize interaction handlers using a temporary map
    map<string, InteractionHandler*> handlerMap;
    const std::vector<InteractionHandler*>& handlers = getInteractionHandlers();
    for (vector<InteractionHandler*>::const_iterator it = handlers.begin(); it != handlers.end(); ++it)
        handlerMap[(*it)->getID()] = *it;
    try {
        s.serialize("InteractionHandlers", handlerMap, "Handler", "name");
    }
    catch (SerializationException& e) {
        LWARNING(e.what());
    }

    s.setUsePointerContentSerialization(usePointerContentSerialization);
    // --- static resources end ---

}
예제 #3
0
void PropertyVector::serialize(XmlSerializer& s) const {
    Property::serialize(s);

    // serialize the properties of the processor
    typedef std::map<std::string, Property*> PropertyMapType;

    PropertyMapType propertyMap;
    for (std::vector<Property*>::const_iterator it = properties_.begin(); it != properties_.end(); ++it)
        propertyMap[(*it)->getID()] = *it;

    const bool usePointerContentSerialization = s.getUsePointerContentSerialization();
    s.setUsePointerContentSerialization(true);
    s.serialize("ElementProperties", propertyMap, "Property", "name");
    s.setUsePointerContentSerialization(usePointerContentSerialization);
}
예제 #4
0
void PropertyOwner::serialize(XmlSerializer& s) const {
    // create temporary property map for serialization
    std::map<std::string, Property*> propertyMap;
    for (std::vector<Property*>::const_iterator it = properties_.begin(); it != properties_.end(); ++it)
        propertyMap[(*it)->getID()] = *it;

    // serialize properties
    const bool usePointerContentSerialization = s.getUsePointerContentSerialization();
    s.setUsePointerContentSerialization(true);
    try {
        s.serialize("Properties", propertyMap, "Property", "name");
    }
    catch (SerializationException& e) {
        LWARNING(e.what());
    }
    s.setUsePointerContentSerialization(usePointerContentSerialization);
}