RulbusInterface.h

00001 /*
00002  * RulbusInterface.h - abstract class RulbusInterface.
00003  *
00004  * This file is part of the Rulbus Device Class Library (RDCL).
00005  *
00006  * Copyright (C) 2003-2004, Leiden University.
00007  *
00008  * This library is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * The library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with mngdriver; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  * $Id: RulbusInterface.h 2 2004-10-12 11:54:15Z moene $
00023  */
00024 
00025 #ifndef __RULBUSINTERFACE_H
00026 #define __RULBUSINTERFACE_H
00027 
00028 #ifndef __COMMON_H
00029 #include "Common.h"
00030 #endif
00031 
00032 #include "Singleton.h"
00033 #include "RulbusInterfaceFactory.h"
00034 
00035 namespace WindowsUtils
00036 {
00037    DECLARE_CLASS( Semaphore );
00038 }
00039 
00040 namespace Rulbus
00041 {
00042    DECLARE_CLASS( TheRulbusInterface );
00043 
00072    class TheRulbusInterface : public Singleton<TheRulbusInterface>
00073    {
00074       friend class Singleton<TheRulbusInterface>;
00075 
00076    public:                                                      // P U B L I C
00079 
00080      static TheRulbusInterfaceRef instance();
00081 
00085 
00086       int          getByte( int rack, int offset           ) const;
00087       int          putByte( int rack, int offset, int byte ) const;
00088 
00092 
00093       virtual bool invariant() const;
00094 
00098 
00099       virtual bool printOn  ( std::ostream& stream ) const = 0; 
00100 
00102 
00103    protected:                                                   // P R O T E C T E D
00106 
00107       TheRulbusInterface();
00108      ~TheRulbusInterface();
00109 
00112 
00113       virtual int  getReg (int offset          ) const = 0;     
00114       virtual int  putReg (int offset, int byte) const = 0;     
00115 
00117 
00118    private:                                                     // P R I V A T E
00119       WindowsUtils::SemaphorePtr s;                             
00120 
00121    public:
00122       static const int ANY_RACK = 0xF;                          
00123    };
00124 
00129    inline TheRulbusInterfaceRef TheRulbusInterface::instance()
00130    {
00131       if ( 0 == theInstance )
00132       {
00133          theInstance = RulbusInterfaceFactory::createInterface();
00134       }
00135 
00136       return *theInstance;
00137    }
00138 
00143    inline bool TheRulbusInterface::invariant() const
00144    {
00145       return true;
00146    }
00147 
00148 }       // namespace Rulbus
00149 
00150 #endif  // __RULBUSINTERFACE_H
00151 
00152 /*
00153  * end of file
00154  */

Generated on Tue Oct 12 14:11:58 2004 for Rulbus Device Class Library for Microsoft Windows by doxygen 1.3.4