DUDS
Distributed Update of Data from Something
DigitalPinAccess.cpp
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  */
11 
12 namespace duds { namespace hardware { namespace interface {
13 
15  DigitalPinAccess &&old
16 ) {
17  // lose access to pin
18  retire();
19  // update the port object of the old object
20  if (old.havePin()) {
21  old.port()->updateAccess(old, this);
22  }
23  // take the old object's data
25  gid = old.gid;
26  return *this;
27 }
28 
29 void DigitalPinAccess::retire() noexcept {
30  if (havePin()) {
31  port()->updateAccess(*this, nullptr);
32  reset();
33  }
34 }
35 
36 } } }
DigitalPort * port() const
Returns a pointer to the port that controls the pin(s) that are operated through this object...
move_impl move(unsigned int c, unsigned int r)
Display stream manipulator that moves the display cursor to the given location.
void reset()
Loses the pointer to the DigitalPort rendering the access object useless.
void retire() noexcept
Relinquish access.
bool havePin() const
Returns true if this object has been given a pin to access.
DigitalPinAccessBase & operator=(DigitalPinAccessBase &&old) noexcept
Allows moving access objects.
void updateAccess(const DigitalPinAccess &oldAcc, DigitalPinAccess *newAcc)
Transfers or relinquishes access to pins.
Provides access to a single pin on a DigitalPort.
DigitalPinAccess & operator=(DigitalPinAccess &&old)
A move assignment.