Changeset 10295
- Timestamp:
- 04/07/11 08:43:01 (14 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventImp.cc
r10183 r10295 112 112 113 113 #include "Time.h" 114 #include "WindowLog.h" 114 115 115 116 using namespace std; … … 199 200 const string str = GetName(); 200 201 if (!str.empty()) 201 out << str;202 out << kBold << str; 202 203 203 204 const string fmt = GetFormat(); 204 205 if (!fmt.empty()) 205 out << "[" << fmt << "]";206 207 out << ":";206 out << kBold << "[" << fmt << "]"; 207 208 out << kReset << ":"; 208 209 209 210 for (unsigned int i=0; i<fAllowedStates.size(); i++) … … 231 232 out << ")"; 232 233 out << endl; 234 235 if (!fDescription.empty()) 236 out << " " << fDescription << endl; 233 237 } 234 238 -
trunk/FACT++/src/EventImp.h
r10183 r10295 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 event 17 16 18 /// http://www.boost.org/doc/libs/1_45_0/libs/bind/bind.html 17 19 boost::function<int(const EventImp &)> fFunction; … … 23 25 EventImp(const EventImp &cmd); 24 26 27 // Description 28 EventImp &SetDescription(const std::string &str) { fDescription=str; return *this; } 29 25 30 // Function handling 26 void AssignFunction(boost::function<int(const EventImp &)> func) { fFunction = func; }31 EventImp &AssignFunction(boost::function<int(const EventImp &)> func) { fFunction = func; return *this; } 27 32 bool HasFunc() const { return !fFunction.empty(); } 28 33 int ExecFunc() const { return HasFunc() ? fFunction(*this) : -1; } 34 35 // Configuration helper 36 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); } 29 39 30 40 // Print contents … … 50 60 51 61 // Getter for all the data contained (name, format, data and time) 52 short GetShort() const { return *reinterpret_cast<const short*>(GetData()); } 53 unsigned short GetUShort() const { return *reinterpret_cast<const unsigned short*>(GetData()); } 54 int GetInt() const { return *reinterpret_cast<const int*>(GetData()); } 55 unsigned int GetUInt() const { return *reinterpret_cast<const unsigned int*>(GetData()); } 56 float GetFloat() const { return *reinterpret_cast<const float*>(GetData()); } 57 double GetDouble() const { return *reinterpret_cast<const double*>(GetData()); } 58 const char *GetText() const { return reinterpret_cast<const char*>(GetData()); } 62 short GetShort() const { return *reinterpret_cast<const short*>(GetData()); } 63 unsigned short GetUShort() const { return *reinterpret_cast<const unsigned short*>(GetData()); } 64 int GetInt() const { return *reinterpret_cast<const int*>(GetData()); } 65 unsigned int GetUInt() const { return *reinterpret_cast<const unsigned int*>(GetData()); } 66 float GetFloat() const { return *reinterpret_cast<const float*>(GetData()); } 67 double GetDouble() const { return *reinterpret_cast<const double*>(GetData()); } 68 const char *GetText() const { return reinterpret_cast<const char*>(GetData()); } 69 std::string GetString() const { return std::string(GetText(), GetSize()); } 70 std::vector<char> GetVector() const { return std::vector<char>(GetText(), GetText()+GetSize()); } 59 71 60 72 };
Note:
See TracChangeset
for help on using the changeset viewer.