Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

LookoutEvents.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_LookoutEvents_h_
00003 #define INCLUDED_LookoutEvents_h_
00004 
00005 #include <iostream>
00006 
00007 #include "EventBase.h"
00008 #include "Crew/LookoutRequests.h"
00009 #include "DualCoding/Sketch.h"
00010 #include "Shared/fmatSpatial.h"
00011 
00012 //! Abstract base class for all Lookout Events
00013 class LookoutEvent : public EventBase {
00014 public:
00015   enum LookoutEventType_t { lookAt, sketch, ir, scan, track, search };
00016   bool success;
00017   virtual LookoutEventType_t getLookoutEventType() const = 0;
00018   //{ constructors which take exact same set of arguments as EventBase's and pass them directory to EventBase
00019   LookoutEvent() : EventBase(), success(false) {}
00020   LookoutEvent(bool _success, EventGeneratorID_t gid, size_t sid, EventTypeID_t tid, unsigned int dur=0)
00021     : EventBase(gid,sid,tid,dur), success(_success) {}
00022   LookoutEvent(bool _success, EventGeneratorID_t gid, size_t sid, EventTypeID_t tid, unsigned int dur, const std::string& n, float mag)
00023     : EventBase(gid,sid,tid,dur,n,mag), success(_success) {}
00024   //}
00025 };
00026 
00027 // This event gives access to transformation matrix from joint specified from LookoutRequest to Base Frame
00028 class LookoutPointAtEvent : public LookoutEvent {
00029 public:
00030   fmat::Transform toBaseMatrix;
00031   virtual LookoutEventType_t getLookoutEventType() const { return lookAt; }
00032   LookoutPointAtEvent() : LookoutEvent(), toBaseMatrix() { }
00033   LookoutPointAtEvent(bool _success, const fmat::Transform& mat) : LookoutEvent(), toBaseMatrix(mat) { success = _success; }
00034   LookoutPointAtEvent(bool _success, const fmat::Transform& mat, EventGeneratorID_t gid, 
00035          size_t sid, EventTypeID_t tid, unsigned int dur=0) 
00036     : LookoutEvent(_success,gid,sid,tid,dur),toBaseMatrix(mat) {}
00037   LookoutPointAtEvent(bool _success, const fmat::Transform& mat, EventGeneratorID_t gid, 
00038          size_t sid, EventTypeID_t tid, unsigned int dur, const std::string& n, float mag)
00039     : LookoutEvent(_success,gid,sid,tid,dur,n,mag), toBaseMatrix(mat) {}
00040   virtual EventBase* clone() const { return new LookoutPointAtEvent(*this); }
00041   virtual unsigned int getClassTypeID() const { return autoRegisterLookoutPointAtEvent; }
00042   virtual std::string getDescription(bool showTypeSpecific=true, unsigned int verbosity=0) const;
00043   virtual unsigned int getBinSize() const;
00044   virtual unsigned int loadBinaryBuffer(const char buf[], unsigned int len);
00045   virtual unsigned int saveBinaryBuffer(char buf[], unsigned int len) const;
00046   virtual void loadXML(xmlNode* node);
00047   virtual void saveXML(xmlNode * node) const;
00048 protected:
00049   //! causes class type id to automatically be regsitered with EventBase's FamilyFactory (getTypeRegistry())
00050   static const EventBase::classTypeID_t autoRegisterLookoutPointAtEvent;
00051 };
00052 
00053 
00054 // Event which gives you access to the sketch stored as a success of StoreImage request
00055 class LookoutSketchEvent : public LookoutPointAtEvent {
00056 protected:
00057   DualCoding::Sketch<DualCoding::uchar> img; // sketch returned by the Lookout
00058   
00059 public:
00060   virtual LookoutEventType_t getLookoutEventType() const { return sketch; }
00061   LookoutSketchEvent() : LookoutPointAtEvent(), img() {}
00062   LookoutSketchEvent(bool _success, DualCoding::Sketch<DualCoding::uchar>& _img, const fmat::Transform& mat)
00063     : LookoutPointAtEvent(_success,mat), img(_img) {}
00064   LookoutSketchEvent(bool _success, DualCoding::Sketch<DualCoding::uchar>& _img, const fmat::Transform& mat, 
00065          EventGeneratorID_t gid, size_t sid, EventTypeID_t tid, unsigned int dur=0) 
00066     : LookoutPointAtEvent(_success, mat,gid,sid,tid,dur), img(_img) {}
00067   LookoutSketchEvent(bool _success, DualCoding::Sketch<DualCoding::uchar>& _img, const fmat::Transform& mat, 
00068          EventGeneratorID_t gid, size_t sid, 
00069          EventTypeID_t tid, unsigned int dur, const std::string& n, float mag)
00070     : LookoutPointAtEvent(_success,mat,gid,sid,tid,dur,n,mag), img(_img) {}
00071   //! copy constructor (shallow copy)
00072   LookoutSketchEvent(const LookoutSketchEvent& other)
00073     : LookoutPointAtEvent(other), img(other.img) {}
00074   
00075   const DualCoding::Sketch<DualCoding::uchar>& getSketch() const { return img; }
00076   virtual EventBase* clone() const { return new LookoutSketchEvent(*this); }
00077   //  virtual std::string getDescription(bool showTypeSpecific=true, unsigned int verbosity=0) const;
00078   
00079   virtual unsigned int getClassTypeID() const { return autoRegisterLookoutSketchEvent; }
00080 protected:
00081   //! causes class type id to automatically be regsitered with EventBase's FamilyFactory (getTypeRegistry())
00082   static const EventBase::classTypeID_t autoRegisterLookoutSketchEvent;
00083 private:
00084   LookoutSketchEvent& operator=(const LookoutSketchEvent&);
00085 };
00086 
00087 class LookoutIREvent : public LookoutPointAtEvent {
00088 public:
00089   float distance;
00090   virtual LookoutEventType_t getLookoutEventType() const { return ir; }
00091   LookoutIREvent() : LookoutPointAtEvent(), distance() {}
00092   LookoutIREvent(bool _success, float dist, const fmat::Transform& mat) : LookoutPointAtEvent(_success,mat), distance(dist) {}
00093   LookoutIREvent(bool _success, float dist, const fmat::Transform& mat, EventGeneratorID_t gid, 
00094      size_t sid, EventTypeID_t tid, unsigned int dur=0) 
00095     : LookoutPointAtEvent(_success, mat, gid,sid,tid,dur), distance(dist) {}
00096   LookoutIREvent(bool _success, float dist, const fmat::Transform& mat, EventGeneratorID_t gid, size_t sid, 
00097      EventTypeID_t tid, unsigned int dur, const std::string& n, float mag)
00098     : LookoutPointAtEvent(_success,mat,gid,sid,tid,dur,n,mag), distance(dist) {}
00099   virtual EventBase* clone() const { return new LookoutIREvent(*this); }
00100   virtual unsigned int getClassTypeID() const { return autoRegisterLookoutIREvent; }
00101   virtual std::string getDescription(bool showTypeSpecific=true, unsigned int verbosity=0) const;
00102   virtual unsigned int getBinSize() const;
00103   virtual unsigned int loadBinaryBuffer(const char buf[], unsigned int len);
00104   virtual unsigned int saveBinaryBuffer(char buf[], unsigned int len) const;
00105   virtual void loadXML(xmlNode* node);
00106   virtual void saveXML(xmlNode * node) const;
00107 protected:
00108   //! causes class type id to automatically be regsitered with EventBase's FamilyFactory (getTypeRegistry())
00109   static const EventBase::classTypeID_t autoRegisterLookoutIREvent;
00110 };
00111 
00112 class LookoutScanEvent : public LookoutEvent {
00113 protected:
00114   //! pointer to tasks implemented during the scan
00115   std::vector<DualCoding::LookoutScanRequest::Task*> *tasks;
00116 public:
00117   virtual LookoutEventType_t getLookoutEventType() const { return scan; }
00118   LookoutScanEvent() : LookoutEvent(), tasks() {}
00119   LookoutScanEvent(std::vector<DualCoding::LookoutScanRequest::Task*>& _tasks) : LookoutEvent(), tasks(&_tasks) {}
00120   LookoutScanEvent(std::vector<DualCoding::LookoutScanRequest::Task*>& _tasks, EventGeneratorID_t gid, 
00121        size_t sid, EventTypeID_t tid, unsigned int dur=0) 
00122     : LookoutEvent(true,gid,sid,tid,dur), tasks(&_tasks) {}
00123   LookoutScanEvent(std::vector<DualCoding::LookoutScanRequest::Task*>& _tasks, EventGeneratorID_t gid, size_t sid, 
00124        EventTypeID_t tid, unsigned int dur, const std::string& n, float mag)
00125     : LookoutEvent(true,gid,sid,tid,dur,n,mag), tasks(&_tasks) {}
00126   //! copy constructor (shallow copy)
00127   LookoutScanEvent(const LookoutScanEvent& lose)
00128     : LookoutEvent(lose), tasks(lose.tasks) {}
00129   //! assignment operator (shallow copy)
00130   const LookoutScanEvent& operator=(const LookoutScanEvent& lose) {
00131     if (this == &lose) return *this;
00132     LookoutEvent::operator=(lose);
00133     tasks = lose.tasks;
00134     return *this;
00135   }
00136   virtual EventBase* clone() const { return new LookoutScanEvent(*this); }
00137   const std::vector<DualCoding::LookoutScanRequest::Task*>& getTasks() const { return *tasks; }
00138   
00139   virtual unsigned int getClassTypeID() const { return autoRegisterLookoutScanEvent; }
00140 protected:
00141   //! causes class type id to automatically be regsitered with EventBase's FamilyFactory (getTypeRegistry())
00142   static const EventBase::classTypeID_t autoRegisterLookoutScanEvent;
00143 };
00144 
00145 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:44 2016 by Doxygen 1.6.3