Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

LOW_platformMisc.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           LOW_platformMisc.h  -  description
00003                              -------------------
00004     begin                : Thu Aug 1 2002
00005     copyright            : (C) 2002 by Harald Roelle, Helmut Reiser
00006     email                : roelle@informatik.uni-muenchen.de, reiser@informatik.uni-muenchen.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef LOW_PLATFORMMISC_H
00019 #define LOW_PLATFORMMISC_H
00020 
00021 
00022 #include "LOW_exception.h"
00023 #include "LOW_platformMiscFactory.h"
00024 
00025 
00026 /** Abstract base class for simple opering system dependent functions.
00027 
00028     The methods are accessed via the public and static access functions.
00029     This class itself takes care of creating an appropiate instance.
00030 
00031     Specific platforms dereive their implementation classes from this class.
00032 
00033     The instances are created by LOW_platformMiscFactory, following the factory
00034     design pattern.
00035 
00036     <B>Note:</B> There is no prescribed constructor. A class deriving from this
00037                  one should only provide the default constructor.<BR>
00038 
00039     @see LOW_platformMiscFactory
00040 
00041     @author Harald Roelle, Helmut Reiser
00042  */
00043 class LOW_platformMisc {
00044 
00045 //=======================================================================================
00046 public: 
00047 
00048   //=====================================================================================
00049   //
00050   // exceptions
00051   //
00052 
00053   /** Exception base class for all exceptions thrown by LOW_platformMisc. */
00054   class_DERIVE_FROM_EXCEPTION( platformMisc_error, LOW_exception);
00055 
00056 
00057   //=====================================================================================
00058   //
00059   // type definitions
00060   //
00061 
00062   /** Data structure for timestamps. */
00063   typedef struct timestamp_t {
00064     long sec;
00065     int  milSec;
00066   } timestamp_t;
00067 
00068   
00069 
00070   //=====================================================================================
00071   //
00072   // static methods
00073   //
00074 
00075   /** Sleep for a specified number of seconds.
00076       @param  inSeconds  Number of seconds to sleep.
00077    */
00078   static const void secSleep( const unsigned int inSeconds);
00079 
00080   /** Sleep for a specified number of milli seconds.
00081       @param  inMilliSeconds  Number of milli seconds to sleep.
00082    */
00083   static const void milliSleep( const unsigned long inMilliSeconds);
00084 
00085   /** Sleep for a specified number of micro seconds.
00086       @param  inMicroSeconds  Number of micro seconds to sleep.
00087    */
00088   static const void microSleep( const unsigned long inMicroSeconds);
00089 
00090   /** Sleep for a specified number of nano seconds.
00091       @param   inNanoSeconds  Number of nano seconds to sleep.
00092    */
00093   static const void nanoSleep( const unsigned long inNanoSeconds);
00094 
00095   /** Sleep for a specified number of nano seconds.
00096       @param  inSeconds      Number of seconds to sleep.
00097       @param  inNanoSeconds  Number of additional nano seconds to sleep.
00098    */
00099   static const void nanoSleep( const unsigned int inSeconds, const unsigned long inNanoSeconds);
00100 
00101 
00102   /** Get a timestamp.
00103       @param  outTimestamp   Where timestamp should be written to.
00104    */
00105   static const void getTimestamp( timestamp_t &outTimestamp);
00106 
00107 
00108   /** Calculate difference of two timestamps.
00109       @param  inT1       A timestamp.
00110       @param  inT2       A timestamp.
00111       @param  outResult  T1-T2.
00112    */
00113   static const void diffTimestamp( const timestamp_t &inT1, const timestamp_t &inT2, timestamp_t &outResult);
00114 
00115 
00116   /** Get identifier for current thread.
00117       @return  Unique identifier for current thread.
00118    */
00119   static const LOW_platformMiscFactory::threadIdent_t  getThreadID();
00120 
00121 
00122   /** Get the host's name.
00123       @return  Host's name.
00124    */
00125   static const std::string getHostname();
00126   
00127   
00128 //=======================================================================================
00129 protected: 
00130 
00131   //=====================================================================================
00132   //
00133   // methods
00134   //
00135   
00136   /** Sleep for a specified number of seconds.
00137       Virtual method to be implemented by OS specific subclasses.
00138       @param  inSeconds  Number of seconds to sleep.
00139    */
00140   virtual const void p_secSleep( const unsigned int inSeconds) = 0;
00141 
00142   /** Sleep for a specified number of milli seconds.
00143       Virtual method to be implemented by OS specific subclasses.
00144       @param  inMilliSeconds  Number of milli seconds to sleep.
00145    */
00146   virtual const void p_milliSleep( const unsigned long inMilliSeconds) = 0;
00147 
00148   /** Sleep for a specified number of micro seconds.
00149       Virtual method to be implemented by OS specific subclasses.
00150       @param  inMicroSeconds  Number of micro seconds to sleep.
00151    */
00152   virtual const void p_microSleep( const unsigned long inMicroSeconds) = 0;
00153 
00154   /** Sleep for a specified number of nano seconds.
00155       Virtual method to be implemented by OS specific subclasses.
00156       @param   inNanoSeconds  Number of nano seconds to sleep.
00157    */
00158   virtual const void p_nanoSleep( const unsigned long inNanoSeconds) = 0;
00159 
00160   /** Sleep for a specified number of nano seconds.
00161       Virtual method to be implemented by OS specific subclasses.
00162       @param  inSeconds      Number of seconds to sleep.
00163       @param  inNanoSeconds  Number of additional nano seconds to sleep.
00164    */
00165   virtual const void p_nanoSleep( const unsigned int inSeconds, const unsigned long inNanoSeconds) = 0;
00166   
00167 
00168   /** Get a timestamp.
00169       Virtual method to be implemented by OS specific subclasses.
00170       @param  outTimestamp   Where timestamp should written to.
00171    */
00172   virtual const void p_getTimestamp( timestamp_t &outTimestamp) = 0;
00173 
00174 
00175   /** Get identifier for current thread.
00176       Virtual method to be implemented by OS specific subclasses.
00177       @return  Unique identifier for current thread.
00178    */
00179   virtual const LOW_platformMiscFactory::threadIdent_t  p_getThreadID() = 0;
00180 
00181 
00182   /** Get the host's name.
00183       Virtual method to be implemented by OS specific subclasses.
00184       @return  Host's name.
00185    */
00186   virtual const std::string p_getHostname() = 0;
00187 
00188 
00189 //=======================================================================================
00190 private: 
00191 
00192   //=====================================================================================
00193   //
00194   // attributes
00195   //
00196 
00197   /** Runtime instance of platform specific implementation of this class.
00198       Having created this instance relieves the burden of explicitely
00199       creating/accessing an instance by users of methods in this class.
00200    */
00201   static LOW_platformMisc  *runtimeInstance;
00202   
00203 };    
00204 
00205 #endif

Generated on Sun Jan 12 21:07:43 2003 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001