Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

IPCMotionHook.cc

Go to the documentation of this file.
00001 #include "IPCMotionHook.h"
00002 #include "IPC/MessageQueue.h"
00003 #include <sstream>
00004 
00005 using namespace std;
00006 
00007 IPCMotionHook::~IPCMotionHook() {
00008   for(msgbuf_t::iterator it=regions.begin();it!=regions.end(); ++it)
00009     (*it)->RemoveReference();
00010 }
00011 
00012 void IPCMotionHook::motionCheck(const float outputs[][NumOutputs]) {
00013   RCRegion * r = getRegion();
00014   memcpy(r->Base(),outputs,r->Size());
00015   mq.sendMessage(r);
00016   regions.push_back(r);
00017 }
00018 
00019 RCRegion* IPCMotionHook::getRegion() {
00020   for(msgbuf_t::iterator it=regions.begin();it!=regions.end(); ++it) {
00021     if((*it)->NumberOfReference()==1) {
00022       RCRegion * ans=*it;
00023       regions.erase(it);
00024       return ans;
00025     }
00026   }
00027   // no unused regions found, make a new one
00028   static int count=0; // how many have we made (unique names for easier debugging)
00029   stringstream ss;
00030   ss << "MotionUpdate." << count++;
00031   cout << "Created " << ss.str() << endl;
00032   return new RCRegion(ss.str(),sizeof(float)*NumOutputs*NumFrames);
00033 }
00034 
00035 
00036 
00037 /*! @file
00038  * @brief 
00039  * @author Ethan Tira-Thompson (ejt) (Creator)
00040  *
00041  * $Author: ejt $
00042  * $Name: tekkotsu-4_0 $
00043  * $Revision: 1.1 $
00044  * $State: Exp $
00045  * $Date: 2007/06/03 17:03:26 $
00046  */

Tekkotsu Hardware Abstraction Layer 4.0
Generated Thu Nov 22 01:00:53 2007 by Doxygen 1.5.4