Changeset 13830 for trunk/FACT++/src


Ignore:
Timestamp:
05/23/12 16:56:18 (12 years ago)
Author:
tbretz
Message:
Removed the target state; added two new member functions GetTimeAsStr and GetJavaDate for convenience
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/EventImp.cc

    r12128 r13830  
    122122//!  fFunction)
    123123//
    124 EventImp::EventImp(const EventImp &cmd) :
    125     fTargetState(cmd.fTargetState), fAllowedStates(cmd.fAllowedStates),
     124EventImp::EventImp(const EventImp &cmd) : fAllowedStates(cmd.fAllowedStates),
    126125    fFunction(cmd.fFunction)
    127126{
     
    242241    for (unsigned int i=0; i<fAllowedStates.size(); i++)
    243242        out << " " << fAllowedStates[i];
    244 
    245     if (fTargetState<0)
    246         out << " (conf)";
    247     else
    248         out << " (trans->" << fTargetState << ")";
    249243
    250244    const Time tm = GetTime();
     
    298292    Print(cout, strip);
    299293}
     294
     295string EventImp::GetTimeAsStr(const char *fmt) const
     296{
     297    return GetTime().GetAsStr(fmt);
     298}
     299
     300uint64_t EventImp::GetJavaDate() const
     301{
     302    return GetTime().JavaDate();
     303}
  • trunk/FACT++/src/EventImp.h

    r12784 r13830  
    1111class EventImp
    1212{
    13     int              fTargetState;   /// Target state of an event
    1413    std::vector<int> fAllowedStates; /// List of states in which this event is allowed
    1514
     
    1918public:
    2019    /// Constructor. Stores the target state given.
    21     EventImp(int target=-1) : fTargetState(target) { }
     20    EventImp() { }
    2221    /// Copy constructor
    2322    EventImp(const EventImp &cmd);
     
    2928
    3029    // Function handling
    31     EventImp &AssignFunction(const std::function<int(const EventImp &)> &func) { fFunction = func; return *this; }
     30    EventImp &AssignFunction(const std::function<int(const EventImp &)> &func=std::function<int(const EventImp &)>()) { fFunction = func; return *this; }
    3231    bool HasFunc() const { return (bool)fFunction; }
    3332    int ExecFunc() const { return fFunction ? fFunction(*this) : -1; }
     
    4948    bool IsStateAllowed(int state) const;
    5049
    51     int  GetTargetState() const { return fTargetState; }
    52 
    5350    // virtual function to return the data as stored in the derived classes
    5451    virtual std::string GetName() const   { return ""; }
     
    5653
    5754    virtual const void *GetData() const { return 0; }
    58     virtual int         GetSize() const { return 0; }
     55    virtual size_t      GetSize() const { return 0; }
    5956
    6057    virtual Time GetTime() const { return Time::None; }
     58    virtual int  GetQoS() const  { return 0; }
     59
     60    std::string GetTimeAsStr(const char *fmt) const;
     61    uint64_t GetJavaDate() const;
    6162
    6263    // Generalized access operators
    6364    template<typename T>
    64         T Get(int offset=0) const
     65        T Get(size_t offset=0) const
    6566    {
    6667        if (offset>=GetSize())
     
    7071
    7172    template<typename T>
    72         const T *Ptr(int offset=0) const
     73        const T *Ptr(size_t offset=0) const
    7374    {
    7475        if (offset>=GetSize())
    7576            throw std::logic_error("EventImp::Ptr - offset out of range.");
    7677        return reinterpret_cast<const T*>(GetText()+offset);
     78    }
     79
     80    template<typename T>
     81        const T &Ref(size_t offset=0) const
     82    {
     83        return *Ptr<T>(offset);
    7784    }
    7885
Note: See TracChangeset for help on using the changeset viewer.