#include #include #include #include using namespace RAT; class MyUserProc : public Processor { public: MyUserProc(); virtual ~MyUserProc() { }; virtual void BeginOfRun(DS::Run& run); virtual Processor::Result DSEvent(DS::Run& run, DS::Entry& ds); protected: int foo; bool happy,sad; std::string bar; std::vector qux; // GetJSON(std::string) returns a Json::Value json::Value baz; }; namespace RAT { Processor *construct_user_proc(std::string /*userProcName*/) { return new MyUserProc; } } MyUserProc::MyUserProc() : Processor("user") { std::cout << "::MyUserProc : Constructing" << std::endl; } void MyUserProc::BeginOfRun(DS::Run& /*run*/) { std::cout << "MyUserProc::BeginOfRun : Initializing" << std::endl; DBLinkPtr l = DB::Get()->GetLink("jsontest"); // the old methods still work foo = l->GetI("foo"); bar = l->GetS("bar"); happy = l->GetZ("happy"); sad = l->GetZ("sad"); // the new DBLinkPtr::GetJSON(std::string) method baz = l->GetJSON("baz"); } Processor::Result MyUserProc::DSEvent(DS::Run& /*run*/, DS::Entry& /*ds*/) { std::cout << "foo : "<< foo << "\n" << "bar : " << bar << "\n"; json::Writer out(std::cout); out.putValue(baz); // get a nested array qux = baz["some_array"].toVector(); for(unsigned i=0; i