DUDS
Distributed Update of Data from Something
DigitalPin.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  const std::shared_ptr<DigitalPort> &port,
16  unsigned int pin
17 ) : DigitalPinBase(port), gid(pin) {
18  // Have a port? Then check for pin non-existence.
19  if (port && !port->exists(pin)) {
20  // bad pin
22  PinErrorId(gid) << DigitalPortAffected(port.get())
23  );
24  };
25 }
26 
27 } } } // namespaces
DigitalPin()=default
Constructs a DigitalPin object without a port or pin.
A pin required for the operation does not exist or is unavailable to the process. ...
Definition: PinErrors.hpp:70
boost::error_info< struct Info_PinId, unsigned int > PinErrorId
The pin global ID involved in the error.
Definition: PinErrors.hpp:97
boost::error_info< struct Info_DigitalPortAffected, const DigitalPort * > DigitalPortAffected
Added to exceptions thrown by DigitalPort objects.
unsigned int gid
Global pin ID.
Definition: DigitalPin.hpp:26
A base class for classes that represent one or more pins on a single DigitalPort, but do not provide ...
#define DUDS_THROW_EXCEPTION(x)
Works like BOOST_THROW_EXCEPTION, but includes a stack trace if DUDS_ERRORS_VERBOSE is defined...
Definition: Errors.hpp:48