OrocosComponentLibrary  2.7.0
ReportingComponent.hpp
00001 /***************************************************************************
00002   tag: Peter Soetens  Mon Jan 19 14:11:26 CET 2004  ReportingComponent.hpp
00003 
00004                         ReportingComponent.hpp -  description
00005                            -------------------
00006     begin                : Mon January 19 2004
00007     copyright            : (C) 2004 Peter Soetens
00008     email                : peter.soetens@mech.kuleuven.ac.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place,                                    *
00024  *   Suite 330, Boston, MA  02111-1307  USA                                *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00028 #ifndef ORO_REPORTING_COMPONENT_HPP
00029 #define ORO_REPORTING_COMPONENT_HPP
00030 
00031 
00032 #include <boost/tuple/tuple.hpp>
00033 
00034 #include <rtt/Property.hpp>
00035 #include <rtt/PropertyBag.hpp>
00036 #include <rtt/marsh/MarshallInterface.hpp>
00037 #include <rtt/os/TimeService.hpp>
00038 #include <rtt/TaskContext.hpp>
00039 
00040 #include <rtt/RTT.hpp>
00041 
00042 #include <ocl/OCL.hpp>
00043 
00044 namespace OCL
00045 {
00081     class ReportingComponent
00082         : public RTT::TaskContext
00083     {
00084     protected:
00088         bool screenImpl( const std::string& comp, std::ostream& output);
00089     public:
00090 
00091         typedef RTT::DataFlowInterface::Ports Ports;
00092 
00096         ReportingComponent( std::string name = "Reporting" );
00097 
00098         virtual ~ReportingComponent();
00099 
00112         bool addMarshaller( RTT::marsh::MarshallInterface* headerM, RTT::marsh::MarshallInterface* bodyM);
00113 
00117         bool removeMarshallers();
00118 
00128         virtual bool configureHook();
00129 
00134         virtual void cleanupHook();
00135 
00140         virtual bool screenComponent( const std::string& comp );
00141 
00145         bool reportComponent( const std::string& component );
00146 
00150         bool unreportComponent( const std::string& component );
00151 
00155         bool reportPort(const std::string& component, const std::string& port );
00156 
00160         bool unreportPort(const std::string& component, const std::string& port );
00161 
00165         bool reportData(const std::string& component,const std::string& dataname);
00166 
00170         bool unreportData(const std::string& component,const std::string& datasource);
00171 
00177         bool copydata();
00178 
00182         void snapshot();
00183 
00184         void cleanReport();
00185 
00188     protected:
00202         typedef boost::tuple<std::string,
00203                              RTT::base::DataSourceBase::shared_ptr,
00204                              std::string,RTT::base::PropertyBase*,RTT::base::InputPortInterface*,bool,bool> DTupple;
00205 
00207         typedef enum { T_QualName = 0, T_PortDS, T_DataType, T_Property, T_Port, T_NewData, T_Tracked } T_Types;
00211         typedef std::vector<DTupple> Reports;
00212         Reports root;
00213 
00214         bool reportDataSource(std::string tag, std::string type, RTT::base::DataSourceBase::shared_ptr origm, RTT::base::InputPortInterface* ipi, bool);
00215 
00216         bool unreportDataSource(std::string tag);
00217 
00218         virtual bool startHook();
00219 
00220         void makeReport2();
00221 
00225         virtual void updateHook();
00226 
00227         virtual void stopHook();
00228 
00229         typedef std::vector< std::pair<boost::shared_ptr<RTT::marsh::MarshallInterface>, boost::shared_ptr<RTT::marsh::MarshallInterface> > > Marshallers;
00230         Marshallers marshallers;
00231         RTT::PropertyBag report;
00232 
00237         bool snapshotted;
00238         RTT::Property<std::string>   config;
00239         RTT::Property<bool>          writeHeader;
00240         RTT::Property<bool>          decompose;
00241         RTT::Property<bool>          insnapshot;
00242         RTT::Property<bool>          synchronize_with_logging;
00243         RTT::Property<PropertyBag>   report_data;
00244         RTT::ConnPolicy              report_policy;
00245         bool                         onlyNewData;
00246 
00247         RTT::os::TimeService::ticks starttime;
00248         RTT::Property<RTT::os::TimeService::Seconds> timestamp;
00250         RTT::internal::DataSource<bool>::shared_ptr mchecker;
00251 
00252     };
00253 
00254 }
00255 
00256 #endif