CountedExample.h

00001 
00002 #ifndef LESTER_COUNTEDEXAMPLE_H
00003 #define LESTER_COUNTEDEXAMPLE_H
00004 
00005 #include "Rabbit.hh"
00006 
00007 #include <ipc/object.h>
00008 #include <iostream>
00009 #include "Sct/RefCountServantBase.h"
00010 
00011 class CountedExample : 
00012   public IPCObject<POA_Stew::CountedExample, // for IPCObjectBase::_destroy()
00013                    ipc::single_thread>, // vital is single thread for serialisation
00014   private Sct::RefCountServantBase 
00015 {
00016   
00017 public:
00018   CountedExample() {
00019     std::cout << "Constructing a CountedExample ... " << std::endl;
00020     // our count starts at one.
00021   };
00022 
00023  public:
00024   virtual ~CountedExample() {
00025     std::cout << "~CountedExample()" << std::endl;
00026   };
00027 
00028   void addRef() {
00029     std::cout << "CountedExample::addCount" << std::endl;
00030     this->_sct_add_ref();
00031   };
00032 
00033   void removeRef() {
00034     std::cout << "CountedExample::removeCount" << std::endl;
00035     this->_sct_remove_ref();
00036 
00037     // when the count gets to zero, 
00038     // this->performCountEqualsZeroAction() gets called
00039   };
00040 
00041   void performCountEqualsZeroAction() {
00042     std::cout << "Moo .. count has reached zero! I think I will commit suicide!" << std::endl;
00043     this->_destroy();
00044   };
00045 
00046 };
00047 
00048 #endif 

Generated on Mon Feb 6 14:01:18 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6