MotionLib  1.0.0
SamBuCa motion library
Public Types | Public Member Functions | Protected Attributes | List of all members
smc::internal::DeviceStore Class Reference
Collaboration diagram for smc::internal::DeviceStore:
Collaboration graph
[legend]

Public Types

typedef std::shared_ptr< DeviceStoreShared
 

Public Member Functions

size_t probeDevices (const PlatformBase::Shared &platform)
 Get devices generated by platform and store them. More...
 
size_t getDeviceCount () const
 Get the number of devices. More...
 
DeviceBase::Shared getDevice (const DeviceId &address) const
 Get the Device with specified address. More...
 
template<typename T >
std::shared_ptr< T > getDevice (const DeviceId &address)
 Convenience function to get a typed device.
 
std::set< DeviceId > getDeviceList () const
 Get the complete list of existing devices.
 
std::set< DeviceId > getDeviceList (DeviceType type) const
 Get list of existing devices. More...
 
std::set< std::string > getAliasList () const
 Get current Alias list.
 
DeviceId getAlias (const std::string &alias) const
 Get the given alias. More...
 
bool addAlias (const std::string &alias, const DeviceId &deviceId, bool override=true)
 add an alias More...
 
void removeAlias (const std::string &alias)
 remove an alias
 
void loadAlias (const ccut::yml::NodeRef &aliasNode, const ccut::yml::Parser *parser=nullptr)
 load alias from yml node
 

Protected Attributes

std::map< DeviceId, DeviceBase::Shared > m_devices
 
std::unordered_map< std::string, DeviceId > m_alias
 
std::mutex m_devicesMutex
 

Detailed Description

Definition at line 51 of file DeviceStore.hpp.

Member Function Documentation

◆ addAlias()

bool smc::internal::DeviceStore::addAlias ( const std::string &  alias,
const DeviceId &  deviceId,
bool  override = true 
)

add an alias

Parameters
[in]aliasthe alias name
[in]deviceIddeviceId to alias
Returns
true if the alias was created
false if alias already exist (and override=false)

Definition at line 117 of file DeviceStore.cpp.

◆ getAlias()

DeviceId smc::internal::DeviceStore::getAlias ( const std::string &  alias) const

Get the given alias.

Returns
the DeviceId associated to this alias
Exceptions
Exception(InvalidArguments)if alias doesn't exist

Definition at line 108 of file DeviceStore.cpp.

◆ getDevice()

std::shared_ptr< DeviceBase > smc::internal::DeviceStore::getDevice ( const DeviceId &  address) const

Get the Device with specified address.

Parameters
addressAddress of required device (DeviceId or alias)
Returns
shared_ptr<DeviceBase> Pointer to device
Exceptions
Exception(InvalidArguments)when device is not found

Definition at line 67 of file DeviceStore.cpp.

Here is the caller graph for this function:

◆ getDeviceCount()

size_t smc::internal::DeviceStore::getDeviceCount ( ) const

Get the number of devices.

Returns
size_t Number of devices

Definition at line 61 of file DeviceStore.cpp.

◆ getDeviceList()

std::set< DeviceId > smc::internal::DeviceStore::getDeviceList ( DeviceType  type) const

Get list of existing devices.

Parameters
[in]typethe type of devices to list
Returns
std::set<DeviceId> list of device Ids of this type

Definition at line 90 of file DeviceStore.cpp.

◆ probeDevices()

size_t smc::internal::DeviceStore::probeDevices ( const PlatformBase::Shared &  platform)

Get devices generated by platform and store them.

Parameters
platformPointer to platform to get devices from
Returns
size_t Number of devices newly generated

Definition at line 45 of file DeviceStore.cpp.


The documentation for this class was generated from the following files: