summaryrefslogtreecommitdiffstats
path: root/kstars/kstars/indi/webcam/PPort.h
blob: c095a6e77e08290667d9ba1e311f1ddbdf631dfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
    Copyright (C) 2004 by Jasem Mutlaq

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

*/

#ifndef _PPort_hpp_
#define _PPort_hpp_

class port_t;

/** To access and share the parallel port
    between severa objects. */
class PPort {
public:
   PPort();
   PPort(int ioPort);
   /** set the ioport associated to the // port.
       \return true if the binding was possible
   */
   bool setPort(int ioPort);
   /** set a data bit of the // port.
       \return false if IO port not set, or bit not registered by ID.
       \param ID the identifier used to register the bit
       \param stat the stat wanted for the given bit
       \param bit the bit to set. They are numbered from 0 to 7.

   */
   bool setBit(const void * ID,int bit,bool stat);
   /** register a bit for object ID.
       \param ID the identifier used to register the bit it should be the 'this' pointer.
       \param bit the bit of the // port to register
       \return false if the bit is allready register with an
               other ID, or if the // port is not initialised.
   */
   bool registerBit(const void * ID,int bit);
   /** release a bit.
       \param ID the identifier used to register the bit
       \param bit the bit to register.
       \return false if the bit was not registered by ID or
               if the if the // port is not initialised.
   */
   bool unregisterBit(const void * ID,int bit);

   /** test if a bit is registerd.
       \param ID the identifier used to register the bit
       \param bit the bit to test.
       \return false if the bit was not registered by ID or
               if the if the // port is not initialised.
   */
   bool isRegisterBit(const void * ID,int bit) const;
   
   /** set the bits off the // port according to previous call to setBit().
    */
   bool commit();
private:
   void reset();
   unsigned char bitArray;
   const void * assignedBit[8];
   port_t * currentPort;
};
#endif