Changeset 10299 for trunk/FACT++/src
- Timestamp:
- 04/07/11 12:39:27 (14 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Event.h
r10183 r10299 7 7 { 8 8 private: 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 11 12 12 std::vector<char> fData; /// Data associated with this event13 std::vector<char> fData; /// Data associated with this event 13 14 14 Time fTime; /// Time stamp15 Time fTime; /// Time stamp 15 16 16 17 public: … … 22 23 Event(const EventImp &imp, const char *name, size_t siz); 23 24 25 void SetDescription(const std::string &str) { fDescription=str; } 26 std::string GetDescription() const { return fDescription; } 24 27 25 28 /// Return the stored name of the event -
trunk/FACT++/src/EventDim.h
r10183 r10299 20 20 #include "dis.hxx" // DimCommand 21 21 22 #include "DimDescriptionService.h" 23 22 24 class EventDim : public EventImp, public DimCommand 23 25 { 26 DimDescriptionService *fDescription; 27 24 28 public: 25 29 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) 27 31 { 28 32 // Initialize these values from DimCommand, because DimCommand … … 34 38 millisecs = 0; 35 39 } 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() : ""; } 36 51 37 52 std::string GetName() const { return const_cast<EventDim*>(this)->getName(); } -
trunk/FACT++/src/EventImp.cc
r10295 r10299 113 113 #include "Time.h" 114 114 #include "WindowLog.h" 115 #include "Description.h" 115 116 116 117 using namespace std; … … 205 206 if (!fmt.empty()) 206 207 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 } 207 217 208 218 out << kReset << ":"; … … 233 243 out << endl; 234 244 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 } 237 260 } 238 261 -
trunk/FACT++/src/EventImp.h
r10295 r10299 14 14 std::vector<int> fAllowedStates; /// List of states in which this event is allowed 15 15 16 std::string fDescription; /// A human readable description of the event17 18 16 /// http://www.boost.org/doc/libs/1_45_0/libs/bind/bind.html 19 17 boost::function<int(const EventImp &)> fFunction; … … 26 24 27 25 // 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 ""; } 29 28 30 29 // Function handling … … 35 34 // Configuration helper 36 35 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; } 39 38 40 39 // Print contents
Note:
See TracChangeset
for help on using the changeset viewer.