NAP
Public Member Functions | List of all members
Device Class Reference

#include <nap/device.h>

Public Member Functions

virtual bool start (utility::ErrorState &errorState)
 
virtual void stop ()
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual bool init (utility::ErrorState &errorState)
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Description

Special type of Resource that represents a device. Only 1 instance of a device is allowed to run at the same time. For example: If you have a device that opens a specific port, that port can't be opened twice. Initialization should fail because of this reason. The solution is to start() and stop() the device when 2 (or more) instances of that same device exist during the real-time edit fase. In this specific case the port is closed when the device is stopped (first instance) before being opened on start (second instance).

The Device class deals with this case by providing an explicit start / stop virtual, which are called at appropriate times by the ResourceManager. It's important that both start & stop can be called multiple times. start is always called before stop. stop is only called when start succeeded.

Inheritance diagram for Device:
[legend]
Collaboration diagram for Device:
[legend]

Member Function Documentation

◆ start()

virtual bool start ( utility::ErrorState errorState)
virtual

Start the device. Called after initialization. When called it is safe to assume that all dependencies have been resolved up to this point.

Parameters
errorStateThe error state
Returns
: true on success

Reimplemented in UDPThread, UDPAdapter, VideoPlayer, SequencePlayer, SerialPort, RenderTag, OSCSender, ArtNetReceiver, OSCReceiver, MidiOutputPort, MidiInputPort, ArtNetController, SecureWebSocketClientEndPoint, WebSocketClientEndPointSetup< config >, and WebSocketClientEndPointSetup< wspp::ConfigTLS >.

◆ stop()

virtual void stop ( )
virtual

Called when the device needs to be stopped, but only if start has previously been called on this Device. It is safe to assume that when stop is called the device is in a 'started' state. Called in reverse init order.

Reimplemented in UDPThread, UDPAdapter, VideoPlayer, SequencePlayer, SerialPort, ArtNetController, RenderTag, OSCSender, WebSocketClientEndPointSetup< config >, WebSocketClientEndPointSetup< wspp::ConfigTLS >, ArtNetReceiver, OSCReceiver, MidiOutputPort, and MidiInputPort.