Libbarrett  1.2.4
include/barrett/products/abstract/special_puck.h
Go to the documentation of this file.
00001 
00033 #ifndef BARRETT_PRODUCTS_ABSTRACT_SPECIAL_PUCK_H_
00034 #define BARRETT_PRODUCTS_ABSTRACT_SPECIAL_PUCK_H_
00035 
00036 
00037 #include <stdexcept>
00038 
00039 #include <barrett/os.h>
00040 #include <barrett/products/puck.h>
00041 
00042 
00043 namespace barrett {
00044 
00045 
00046 class SpecialPuck {
00047 public:
00049         SpecialPuck(enum Puck::PuckType _type = Puck::PT_Unknown) :
00050                 type(_type), p(NULL) {}
00051         ~SpecialPuck() {}
00053         Puck* getPuck() const { return p; }
00055         void setPuck(Puck* puck) {
00056                 if (puck != NULL  &&  type != Puck::PT_Unknown  &&  puck->getType() != type) {
00057                         (logMessage("SpecialPuck::%s(): Bad PuckType. "
00058                                         "Expected Puck with type %s, got Puck with type %s.")
00059                                         % __func__ % Puck::getPuckTypeStr(type) % Puck::getPuckTypeStr(puck->getType())
00060                         ).raise<std::logic_error>();
00061                 }
00062                 p = puck;
00063         }
00064 
00065 protected:
00066         enum Puck::PuckType type;
00067         Puck* p;
00068 };
00069 
00070 
00071 }
00072 
00073 
00074 #endif /* BARRETT_PRODUCTS_ABSTRACT_SPECIAL_PUCK_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Defines