#include "MyClass.h" #include "TBuffer.h" #include "TClass.h" /*! @brief Custom streamer for MyClass. * * In this simple example MyClass is supposed to have 2 members: value1 and value2. * */ void MyClassStreamer(TBuffer &buf, void *objPtr) { MyClass *myObj = (MyClass *)objPtr; if (buf.IsReading()) { buf >> myObj->value1; buf >> myObj->value2; } else { buf << myObj->value1; buf << myObj->value2; } } /*! @brief Proxy class for automatic registration of the custom streamer. */ class MyClassStreamerProxy { public: MyClassStreamerProxy() { auto *tClass = TClass::GetClass("MyClass"); if (tClass) tClass->SetStreamerFunc(MyClassStreamer); else throw(std::runtime_error("MyClassStreamerProxy: dictionary for MyClass is not available")); } }; /*! @brief Proxy object for automatic registration of the custom streamer. */ MyClassStreamerProxy myClassStreamerProxy;