solarpowerlog trunk
/home/tobi/workspace/solarpowerlog/src/Connections/CAsyncCommand.h
Go to the documentation of this file.
00001 /*
00002  * CAsyncCommand.h
00003  *
00004  *  Created on: Dec 14, 2009
00005  *      Author: tobi
00006  */
00007 
00008 #ifndef CASYNCCOMMAND_H_
00009 #define CASYNCCOMMAND_H_
00010 
00011 #include <semaphore.h>
00012 #include "patterns/ICommand.h"
00013 
00014 class CAsyncCommand
00015 {
00016 public:
00017      enum Commando
00018      {
00019           DISCONNECT, 
00020           CONNECT, 
00021           SEND, 
00022           RECEIVE,
00024      };
00025 
00035      CAsyncCommand( enum Commando c, ICommand *callback, sem_t *sem = NULL );
00036 
00038      ~CAsyncCommand();
00039 
00042      inline void SetSemaphore( sem_t *sem )
00043      {
00044           this->sem = sem;
00045      }
00046 
00047 
00051      void HandleCompletion( void );
00052 
00059      inline bool IsAsynchronous()
00060      {
00061           return !private_icommand;
00062      }
00063 
00064      enum Commando c; 
00065 
00071      ICommand *callback;
00072 
00073 private:
00074      sem_t *sem; 
00075 
00076 
00077 
00078      bool private_icommand;
00079 
00080 };
00081 #endif /* CASYNCCOMMAND_H_ */