Changeset 10299


Ignore:
Timestamp:
Apr 7, 2011, 12:39:27 PM (9 years ago)
Author:
tbretz
Message:
Implemented event description into all kind of events.
Location:
trunk/FACT++/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Event.h

    r10183 r10299  
    77{
    88private:
    9     std::string fName;       /// A name associated with the event
    10     std::string fFormat;     /// A string describing the format of the data
     9    std::string fName;        /// A name associated with the event
     10    std::string fFormat;      /// A string describing the format of the data
     11    std::string fDescription; /// A human readable description of the event
    1112
    12     std::vector<char> fData; /// Data associated with this event
     13    std::vector<char> fData;  /// Data associated with this event
    1314
    14     Time  fTime;             /// Time stamp
     15    Time  fTime;              /// Time stamp
    1516
    1617public:
     
    2223    Event(const EventImp &imp, const char *name, size_t siz);
    2324
     25    void SetDescription(const std::string &str) { fDescription=str; }
     26    std::string GetDescription() const { return fDescription; }
    2427
    2528    /// Return the stored name of the event
  • trunk/FACT++/src/EventDim.h

    r10183 r10299  
    2020#include "dis.hxx" // DimCommand
    2121
     22#include "DimDescriptionService.h"
     23
    2224class EventDim : public EventImp, public DimCommand
    2325{
     26    DimDescriptionService *fDescription;
     27
    2428public:
    2529    EventDim(int target, const std::string &name, const std::string &format, DimCommandHandler *handler)
    26         : EventImp(target), DimCommand(name.c_str(), format.c_str(), handler)
     30        : EventImp(target), DimCommand(name.c_str(), format.c_str(), handler), fDescription(0)
    2731    {
    2832        // Initialize these values from DimCommand, because DimCommand
     
    3438        millisecs = 0;
    3539    }
     40    ~EventDim()
     41    {
     42        delete fDescription;
     43    }
     44    void SetDescription(const std::string &str)
     45    {
     46        if (fDescription)
     47            delete fDescription;
     48        fDescription = new DimDescriptionService(GetName(), str);
     49    }
     50    std::string GetDescription() const { return fDescription ? fDescription->GetDescription() : ""; }
    3651
    3752    std::string GetName() const   { return const_cast<EventDim*>(this)->getName(); }
  • trunk/FACT++/src/EventImp.cc

    r10295 r10299  
    113113#include "Time.h"
    114114#include "WindowLog.h"
     115#include "Description.h"
    115116
    116117using namespace std;
     
    205206    if (!fmt.empty())
    206207        out << kBold << "[" << fmt << "]";
     208
     209    vector<Description> v = Description::SplitDescription(GetDescription());
     210
     211    if (!GetDescription().empty())
     212    {
     213        for (vector<Description>::const_iterator j=v.begin()+1;
     214             j!=v.end(); j++)
     215            out << " <" << j->name << ">";
     216    }
    207217
    208218    out << kReset << ":";
     
    233243    out << endl;
    234244
    235     if (!fDescription.empty())
    236         out << "     " << fDescription << endl;
     245    if (GetDescription().empty())
     246        return;
     247
     248    out << "   " << v[0].comment << endl;
     249
     250    for (vector<Description>::const_iterator j=v.begin()+1;
     251         j!=v.end(); j++)
     252    {
     253        out << "    " << kGreen << j->name;
     254        if (!j->comment.empty())
     255            out << kReset << ": " << kBlue << j->comment;
     256        if (!j->unit.empty())
     257            out << kYellow << " [" << j->unit << "]";
     258        out << endl;
     259    }
    237260}
    238261
  • trunk/FACT++/src/EventImp.h

    r10295 r10299  
    1414    std::vector<int> fAllowedStates; /// List of states in which this event is allowed
    1515
    16     std::string      fDescription;   /// A human readable description of the event
    17 
    1816    /// http://www.boost.org/doc/libs/1_45_0/libs/bind/bind.html
    1917    boost::function<int(const EventImp &)> fFunction;
     
    2624
    2725    // Description
    28     EventImp &SetDescription(const std::string &str) { fDescription=str; return *this; }
     26    virtual void SetDescription(const std::string &) { }
     27    virtual std::string GetDescription() const { return ""; }
    2928
    3029    // Function handling
     
    3534    // Configuration helper
    3635    EventImp &operator()(boost::function<int(const EventImp &)> func) { return AssignFunction(func); }
    37     EventImp &operator()(const std::string str) { return SetDescription(str); }
    38     EventImp &operator()(const char *str) { return SetDescription(str); }
     36    EventImp &operator()(const std::string str) { SetDescription(str); return *this; }
     37    EventImp &operator()(const char *str) { SetDescription(str); return *this; }
    3938
    4039    // Print contents
Note: See TracChangeset for help on using the changeset viewer.