• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

include/base/OperList.h (r4864/r3097)

Go to the documentation of this file.
00001 #ifndef BASE_OPERLIST_H
00002 #define BASE_OPERLIST_H
00003 
00004 #include <vector>
00005 
00006 #include <stdint.h>
00007 
00008 namespace base {
00009 
00010    struct Oper {
00011       bool     isput;
00012       uint32_t addr;
00013       uint32_t value;
00014 
00015       Oper() : isput(false), addr(0), value(0) {}
00016 
00017       Oper(bool _isput, uint32_t _addr, uint32_t _value = 0) :
00018          isput(_isput),
00019          addr(_addr),
00020          value(_value)
00021       {
00022       }
00023 
00024       Oper(const Oper& src) :
00025          isput(src.isput),
00026          addr(src.addr),
00027          value(src.value)
00028       {
00029       }
00030 
00031    };
00032 
00033    class OperList {
00034       protected:
00035          std::vector<Oper>  fList;
00036 
00037          int               fErrorOper; // number of operation failed, -1 ok
00038          int               fErrorCode; // error code of operation, 0 - ok
00039 
00040       public:
00041          OperList();
00042          OperList(int noper, bool* isput, uint32_t* addr, uint32_t* value);
00043          OperList(const OperList& src);
00044          virtual ~OperList();
00045 
00046          int number() const { return (int) fList.size(); }
00047          Oper& oper(int n) { return fList[n]; }
00048          const Oper& oper(int n) const { return fList[n]; }
00049          bool isput(int n) const { return oper(n).isput; }
00050 
00051          void clear() { fList.clear(); fErrorOper = -1; fErrorCode = 0; }
00052 
00053          void addOper(const Oper& oper)
00054            { fList.push_back(oper); }
00055 
00056          void addOper(bool isput, uint32_t addr, uint32_t value)
00057            { addOper(Oper(isput, addr, value)); }
00058 
00059          void addPut(uint32_t addr, uint32_t value) { addOper(true, addr, value); }
00060 
00061          void addGet(uint32_t addr) { addOper(false, addr, 0); }
00062 
00063          void print();
00064 
00065          int getErrorOper() const { return fErrorOper; }
00066          void setErrorOper(int n) { fErrorOper = n; }
00067 
00068          int getErrorCode() const { return fErrorCode; }
00069          void setErrorCode(int code) { fErrorCode = code; }
00070    };
00071 
00072 }
00073 
00074 #endif

Generated on Tue Dec 10 2013 04:52:22 for ROCsoft by  doxygen 1.7.1