SMBIOS Library
CmosRWImpl.h
Go to the documentation of this file.
1 // vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:
2 /*
3  * Copyright (C) 2005 Dell Inc.
4  * by Michael Brown <Michael_E_Brown@dell.com>
5  * Licensed under the Open Software License version 2.1
6  *
7  * Alternatively, you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published
9  * by the Free Software Foundation; either version 2 of the License,
10  * or (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  * See the GNU General Public License for more details.
16  */
17 
18 #ifndef CMOSRWIMPL_H
19 #define CMOSRWIMPL_H
20 
21 #include "smbios/IObserver.h"
22 #include "smbios/ICmosRW.h"
23 #include "ExceptionImpl.h"
24 
25 namespace cmos
26 {
27  // define our exceptions
28  DEFINE_EXCEPTION_EX( InvalidCmosRWModeImpl, cmos, InvalidCmosRWMode );
29 
31  {
32  public:
33  Suppressable();
34  void suppressNotification(bool sup = true) const;
35  void resumeNotification(bool doNotify = true) const;
36  bool isNotifySuppressed() const;
37  virtual ~Suppressable();
38 
39  protected:
40  mutable bool suppressNotify;
41  };
42 
43  class CmosRWFile : public ICmosRW, public Suppressable
44  {
45  public:
46  // CONSTRUCTORS, DESTRUCTOR, and ASSIGNMENT
47  explicit CmosRWFile (const std::string &File);
48  CmosRWFile& operator = (const CmosRWFile & source);
49  virtual ~CmosRWFile();
50 
51  u8 readByte( u32 indexPort, u32 dataPort, u32 offset ) const;
52  void writeByte( u32 indexPort, u32 dataPort, u32 offset, u8 byte ) const;
53 
54  protected:
55  std::string fileName;
56 
57  private:
58  CmosRWFile (const CmosRWFile & source); //copy constructor
59  };
60 
61 
62  class CmosRWIo : public ICmosRW, public Suppressable
63  {
64  public:
65  // CONSTRUCTORS, DESTRUCTOR, and ASSIGNMENT
66  explicit CmosRWIo ();
67  CmosRWIo& operator = (const CmosRWIo & source);
68  virtual ~CmosRWIo();
69 
70  u8 readByte( u32 indexPort, u32 dataPort, u32 offset ) const;
71  void writeByte( u32 indexPort, u32 dataPort, u32 offset, u8 byte ) const;
72  private:
73  CmosRWIo (const CmosRWIo & source); //copy constructor
74  };
75 
76 }
77 
78 
79 #endif /* CMOSRWIMPL_H */