00001 #ifndef __INSTANTIO_BASICINSLOT_H
00002 #define __INSTANTIO_BASICINSLOT_H
00003
00004 #ifdef _MSC_VER
00005 # pragma once
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "InstantIODef.h"
00027 #include "Slot.h"
00028 #include <string>
00029 #include <set>
00030 namespace Medusa
00031 {
00032 class Semaphore;
00033 }
00034 #ifdef _MSC_VER
00035 # pragma warning (push)
00036 # pragma warning (disable: 4251)
00037 #endif
00038
00039
00040 namespace InstantIO
00041 {
00042
00043
00044 class BasicOutSlot;
00045
00046
00057 class INSTANTIO_DLLMAPPING BasicInSlot: public Slot
00058 {
00059 public:
00060
00083 class INSTANTIO_DLLMAPPING Listener
00084 {
00085 public:
00086
00088 virtual ~Listener();
00089
00099 virtual void startInSlot(BasicInSlot &inSlot);
00100
00110 virtual void stopInSlot(BasicInSlot &inSlot);
00111
00121 virtual void newData(BasicInSlot &inSlot);
00122 };
00123
00127 virtual ~BasicInSlot();
00128
00133 virtual Direction getDirection() const;
00134
00156 void addListener(Listener &listener);
00157
00165 void removeListener(Listener &listener);
00166
00175 virtual bool empty() const = 0;
00176
00180 void interrupt();
00181
00200 virtual void connect(BasicOutSlot *outSlot) = 0;
00201
00217 virtual void disconnect(BasicOutSlot *outSlot) = 0;
00218
00219 protected:
00220
00228 explicit BasicInSlot(const std::string &description = std::string());
00229
00238 virtual void startInSlot();
00239
00248 virtual void stopInSlot();
00249
00259 virtual void newData();
00260
00265 void up() const;
00266
00271 void down() const;
00272
00274
00275 bool interrupted_;
00276
00277 private:
00278
00280 typedef std::set<Listener*> ListenerSet;
00281
00283
00284 ListenerSet listeners_;
00285
00287 Medusa::Semaphore *semaphore_;
00288
00290 BasicInSlot(const BasicInSlot &);
00291
00293 const BasicInSlot &operator=(const BasicInSlot &);
00294 };
00295
00296
00297 }
00298
00299
00300 #ifdef _MSC_VER
00301 # pragma warning (pop)
00302 #endif
00303
00304 #endif //__INSTANTIO_BASICINSLOT_H