Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields  

SharedVar.h

00001 /*
00002  * $Id: SharedVar.h,v 1.3 2002/08/11 06:25:12 mindstorm2600 Exp $
00003  */
00004 #ifndef __SHARED_VAR_H__
00005 #define __SHARED_VAR_H__
00006 #include<Mutex.h>
00007 
00008 
00009 namespace clawsoft{
00010 
00013         template <class T> 
00014         class SharedVar:protected Mutex{
00015                 private:
00017                         T var;
00018                 public:
00020                         T getValue(T v = 0){
00021                                 lock();
00022                                 v = var;
00023                                 unlock();
00024                                 return v;
00025                         }
00027                         void setValue(T v = 0){
00028                                 lock();
00029                                 var = v;
00030                                 unlock();
00031                         }
00033                         SharedVar(){;}
00035                         SharedVar(T v){
00036                                 setValue(v);
00037                         }
00039                         T operator++(int XXX = 0){
00040                                 T u= 0;
00041                                 lock();
00042                                 u = var++;
00043                                 unlock();
00044                                 return u;
00045                         }
00047                         T operator--(int XXX = 0){
00048                                 T u= 0;
00049                                 lock();
00050                                 u = var--;
00051                                 unlock();
00052                                 return u;
00053                         }
00054         };
00055 };
00056 
00057 #endif
00058 

Authors:

Juan V. Guerrero
Jannette C. Mejia
Juan C. Guevara

Powered by:

SourceForgeLogo