DUDS
Distributed Update of Data from Something
DigitalPinAccessBase.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2017 Jeff Jackowski
9  */
10 #ifndef DIGITALPINACCESSBASE_HPP
11 #define DIGITALPINACCESSBASE_HPP
12 
13 #include <boost/noncopyable.hpp>
14 #include <cstdint>
15 
16 namespace duds { namespace hardware { namespace interface {
17 
18 class DigitalPort;
19 
27 class DigitalPinAccessBase : boost::noncopyable {
28 public:
33  union PortData {
39  void *pointer;
45  std::intptr_t integer;
51  std::int16_t int16[2];
55  PortData() : pointer(nullptr) { }
56  };
57 private:
62  friend DigitalPort;
63 protected:
68  mutable PortData portdata;
73  DigitalPinAccessBase() : dp(nullptr) { };
83  ~DigitalPinAccessBase() = default;
92  void reset() {
93  dp = nullptr;
94  }
95 public:
106  DigitalPort *port() const {
108  return dp;
109  }
110 };
111 
112 } } }
113 
114 #endif // #ifndef DIGITALPINACCESSBASE_HPP
PortData()
Default contructor ensures a null pointer.
DigitalPort * port() const
Returns a pointer to the port that controls the pin(s) that are operated through this object...
DigitalPinAccessBase(DigitalPort *port)
Initializes the port pointer.
Represents an interface to a group of hardware related digital GPIO lines.
Definition: DigitalPort.hpp:47
DigitalPinAccessBase()
Cannot be constructed using this base class, but allows the construction of a useless access object w...
void reset()
Loses the pointer to the DigitalPort rendering the access object useless.
std::int16_t int16[2]
Two integers available for use by DigitalPort implementations to manage additional implementation spe...
A type for holding arbitrary port-specific data within a DigitalPinAccess or DigitalPinSetAccess obje...
PortData portdata
Port specific information.
DigitalPinAccessBase & operator=(DigitalPinAccessBase &&old) noexcept
Allows moving access objects.
The base class for the digital pin access classes.
DigitalPort * dp
A pointer to the port object handling the pin(s).
void * pointer
A pointer available for use by DigitalPort implementations to manage additional implementation specif...
std::intptr_t integer
An integer available for use by DigitalPort implementations to manage additional implementation speci...
~DigitalPinAccessBase()=default
Cannot be destructed using this base class to avoid the need for a virtual destructor.