Skip to content

Class upisnd::Element#

Detailed Description#

It takes care of adding and releaseing references to the underlying C API element, it follows the usual C++ class semantics.

It also provides a safe templated as() method for casting to the appropriate class.

You may use the Element::setup method to create a new element from a upisnd_setup_t setup option container.

  • #include <element.h>

Inherited by the following classes: upisnd::Activity, upisnd::AnalogInput, upisnd::Encoder, upisnd::Gpio

Public Functions#

Type Name
Element ()
Element (upisnd_element_ref_t el)
Implicitly increments the refcount. If you got the element from C API, don't forget to unref it afterwards.
Element (const Element & rhs)
Element & operator= (const Element & rhs)
Element (Element && rhs)
Element & operator= (Element && rhs)
~Element ()
Unreferences the element.
bool isValid () const
Checks if the element is valid.
void release ()
Unreferences the underlying C upisnd_element_ref_t handle and resets the object.
const char * getName () const
Gets the name of the element.
upisnd_element_type_e getType () const
Gets the type of the element.
upisnd_pin_t getPin () const
Gets the pin of the element.
ValueFd openValueFd (int flags) const
Opens the Element 'svalue attribute as a file descriptor.
T as () const
Safely casts the element to the requested class. Returns an invalid object if the cast is not possible.

Public Static Functions#

Type Name
Element get (ElementName name)
Gets an Element followingupisnd_element_get semantics.
Element setup (ElementName name, upisnd_setup_t setup)
Sets up a new Element from aupisnd_setup_t setup option container.

Protected Functions#

Type Name
upisnd_element_ref_t ref () const
Element (upisnd_element_ref_t el, bool)

Element [1/5]#

upisnd::Element::Element () 

Element [2/5]#

Implicitly increments the refcount. If you got the element from C API, don't forget to unref it afterwards.

explicit upisnd::Element::Element (
    upisnd_element_ref_t el
) 


Element [3/5]#

upisnd::Element::Element (
    const Element & rhs
) 

operator=#

Element & upisnd::Element::operator= (
    const Element & rhs
) 

Element [4/5]#

upisnd::Element::Element (
    Element && rhs
) 

operator=#

Element & upisnd::Element::operator= (
    Element && rhs
) 

~Element#

Unreferences the element.

upisnd::Element::~Element () 


isValid#

Checks if the element is valid.

bool upisnd::Element::isValid () const


release#

Unreferences the underlying C upisnd_element_ref_t handle and resets the object.

void upisnd::Element::release () 


getName#

Gets the name of the element.

const char * upisnd::Element::getName () const


getType#

Gets the type of the element.

upisnd_element_type_e upisnd::Element::getType () const


getPin#

Gets the pin of the element.

upisnd_pin_t upisnd::Element::getPin () const


openValueFd#

Opens the Element 'svalue attribute as a file descriptor.

ValueFd upisnd::Element::openValueFd (
    int flags
) const

Parameters:

  • flags The flags to pass to ::open.

See also: upisnd_element_open_value_fd


as#

Safely casts the element to the requested class. Returns an invalid object if the cast is not possible.

template<typename T>
inline T upisnd::Element::as () const


get#

Gets an Element followingupisnd_element_get semantics.

static Element upisnd::Element::get (
    ElementName name
) 

Parameters:

  • name The name of the element to get. Can be provided as a string constant or const char *.

setup#

Sets up a new Element from aupisnd_setup_t setup option container.

static Element upisnd::Element::setup (
    ElementName name,
    upisnd_setup_t setup
) 

Parameters:

  • name The name of the element to get. Can be provided as a string constant or const char *.
  • setup The setup option container. See upisnd_setup_set_element_type and the rest of the upisnd_setup_* APIs in api.h.

ref#

inline upisnd_element_ref_t upisnd::Element::ref () const

Element [5/5]#

upisnd::Element::Element (
    upisnd_element_ref_t el,
    bool
)