The Serializable class is the top class of all xdata data types. The interface, depicted below, is currently very spartan.


namespace xdata {

    class Serializable 
            virtual std::string type() const = 0;
            virtual void setValue (const Serializable& s);

            virtual int equals(const xdata::Serializable & s) = 0;

You can retrieve the type of the xdata object through the type() function. If you want to use the value contained by the serializable you need to downcast it to the concrete type. Then you can get a hand on the value contained or convert it to a string. The code snippet demonstrating this has been taken from a callback of an InfoSpace event. The event contains the pointer of the modified xdata::Serializable value. To access it it needs to be downcasted.

void actionPerformed(xdata::Event & received ) {

    xdata::ItemEvent& e = dynamic_cast(received);
    xdata::Serializable* s = e.item();
    if (s->type() == "int")
        xdata::Integer * i = dynamic_cast(s);
        std::cout << "value as integer: " << (int)*i  << std::endl;            
        std::cout << "value as string : " << i->toString() << std::endl;  


Future releases will contain an augmented interface to allow for more powerful manipulations.

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2005-05-11 - JohannesGutleber
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    XdaqWiki/Xdata All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback