serialization layer for QuantLIbAddin objects

Posted by Plamen Neykov on
URL: http://quantlib.414.s1.nabble.com/serialization-layer-for-QuantLIbAddin-objects-tp10977.html

Hi folks,

Eric and I have discussed a possible implementation of a serialization layer
for QLA objects. The first step would be to implement so called
"ValueObjects" generated out of the xml description of the constructor
functions (The assumption here is that the data set supplied to the
constructor is sufficient to describe the object). The generated
"ValueObject" will then provide functions for serialization - multiple
sierialization methods are possible. In addition some generic method for
accessing properties may be also implemented. E.g. the generated class might
look something like this:

class VSimpleSwap : public ValueObject {
public:
  long StartDate;
  long MaturityDate;
  // rest properties....

  void serialize(....) {
    //implements boost::serialize method
  }

  std::string toXML() const {
    // implement some xml based export
  }

  std::string getProperty(const std::string& name) const {
    if(name == "StartDate") return lexical_cast<std::string>(StartDate);
    else if(name == "MaturityDate")
       return lexical_cast<std::string>(MaturityDate);
        .........................
  }
 
  std::vector<std::string> getPropertyNames() const {
    std::vector<std::string> names;
    names.push_back("StartDate");
    names.push_back("MaturityDate");
    // rest properties ...
    return names;
  }
};

Based on those ValueObjects generic layers for persistence and remoting for
QLA objects can be developed. Also a generic XSLT processing layer might be
also developed to convert the simple xml stream into FpML or any other xml
dialect.


I'll be very happy about comments and suggestions.

cheers,
Plamen

attachment0 (189 bytes) Download Attachment