DUDS
Distributed Update of Data from Something
DigitalPinBase.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 DIGITALPINBASE_HPP
11 #define DIGITALPINBASE_HPP
12 
13 #include <memory>
14 
15 namespace duds { namespace hardware { namespace interface {
16 
17 class DigitalPort;
18 
29  std::shared_ptr<DigitalPort> dp;
30 protected:
35  DigitalPinBase() = default;
41  ~DigitalPinBase() = default;
45  DigitalPinBase(const std::shared_ptr<DigitalPort> &port) : dp(port) { }
46 public:
51  const std::shared_ptr<DigitalPort> &port() const {
52  return dp;
53  }
58  void reset() {
59  dp.reset();
60  }
61 };
62 
63 } } }
64 
65 #endif // #ifndef DIGITALPINBASE_HPP
~DigitalPinBase()=default
Cannot be destructed using this base class to avoid the need for a virtual destructor.
std::shared_ptr< DigitalPort > dp
The port object that can grant access to the pin(s).
const std::shared_ptr< DigitalPort > & port() const
Returns the port that grants access to the pin(s) referenced by this object.
void reset()
Resets the shared pointer to the DigitalPort so that this object no longer represents a pin...
DigitalPinBase()=default
Cannot be constructed using this base class, but allows the construction of a useless object without ...
DigitalPinBase(const std::shared_ptr< DigitalPort > &port)
Initializes the port.
A base class for classes that represent one or more pins on a single DigitalPort, but do not provide ...