// TrfReportingObject.h #ifndef trf__TrfReportingObject_H #define trf__TrfReportingObject_H // TrfObject with a list of reporters. #include #include "ptr/Ptr.h" #include "ptr/LocalSharedDeletePolicy.h" #include "TrfObject.h" #include "Message.h" #include "Reporter.h" #include "ReporterPtr.h" namespace trf { class TrfReportingObject : public TrfObject { public: // typedefs // List of reporters. typedef std::vector ReporterList; private: // data // List of reporters. mutable ReporterList _reps; public: // methods // Send a message to all reporters. // The following method may be used to avoid creating the message // when no reporters are assigend. void report(const AbsMessage& msg) const; // This template member creates the message and then sends it to // all reporters. If there are no reporters, the message is not // created. template void make_report(const Sender& sender, std::string loc, const Data& data) const { if ( _reps.size() ) { report( Message(sender,loc,data) ); } } public: // methods // Add a reporter. void add_reporter(Reporter* rep); // Return the list of reporters. const ReporterList& reporters() const { return _reps; }; }; // TrfReportingObject pointer. typedef Ptr TrfReportingObjectPtr; // List of TrfReportingObjects typedef std::vector TrfReportingObjectList; } // end namespace #endif