YARP  2.3.68+220-20170323.2+git4955ef0
Yet Another Robot Platform
yarp::os::SharedLibraryFactory Class Reference

A wrapper for a named factory method in a named shared library. More...

#include <yarp/os/SharedLibraryFactory.h>

+ Inheritance diagram for yarp::os::SharedLibraryFactory:

Public Types

enum  {
  STATUS_NONE,
  STATUS_OK = VOCAB2('o','k'),
  STATUS_LIBRARY_NOT_FOUND = VOCAB4('f','o','u','n'),
  STATUS_LIBRARY_NOT_LOADED = VOCAB4('l','o','a','d'),
  STATUS_FACTORY_NOT_FOUND = VOCAB4('f','a','c','t'),
  STATUS_FACTORY_NOT_FUNCTIONAL = VOCAB3('r','u','n')
}
 The status of a factory can be: More...
 

Public Member Functions

 SharedLibraryFactory ()
 Constructor for unconfigured factory. More...
 
 SharedLibraryFactory (const char *dll_name, const char *fn_name=YARP_NULLPTR)
 Constructor. More...
 
virtual ~SharedLibraryFactory ()
 Destructor. More...
 
bool open (const char *dll_name, const char *fn_name=YARP_NULLPTR)
 Configure the factory. More...
 
bool isValid () const
 Check if factory is configured and present. More...
 
int getStatus () const
 Get the status of the factory. More...
 
ConstString getError () const
 Get the latest error of the factory. More...
 
const SharedLibraryClassApigetApi () const
 Get the factory API, which has creation/deletion methods. More...
 
int getReferenceCount () const
 Get the current reference count of this factory. More...
 
int addRef ()
 Increment the reference count of this factory. More...
 
int removeRef ()
 Decrement the reference count of this factory. More...
 
ConstString getName () const
 Get the name associated with this factory. More...
 
ConstString getClassName () const
 Get the type associated with this factory. More...
 
ConstString getBaseClassName () const
 Get the base type associated with this factory. More...
 
bool useFactoryFunction (void *factory)
 Specify function to use as factory. More...
 

Private Attributes

SharedLibrary lib
 
int status
 
SharedLibraryClassApi api
 
int returnValue
 
int rct
 
ConstString name
 
ConstString className
 
ConstString baseClassName
 
ConstString error
 

Detailed Description

A wrapper for a named factory method in a named shared library.

This wrapper will do some basic checks that the named method does indeed behave like a YARP plugin hook before offering access to it. This is to avoid accidents, it is not a security mechanism.

Definition at line 29 of file SharedLibraryFactory.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

The status of a factory can be:

  • STATUS_NONE: Not configured yet
  • STATUS_OK: Present and sane
  • STATUS_LIBRARY_NOT_FOUND: Named shared library was not found
  • STATUS_LIBRARY_NOT_LOADED: Named shared library failed to load
  • STATUS_FACTORY_NOT_FOUND: Named method wasn't present in library
  • STATUS_FACTORY_NOT_FUNCTIONAL: Named method is not working right
Enumerator
STATUS_NONE 

Not configured yet.

STATUS_OK 

Present and sane.

STATUS_LIBRARY_NOT_FOUND 

Named shared library was not found.

STATUS_LIBRARY_NOT_LOADED 

Named shared library failed to load.

STATUS_FACTORY_NOT_FOUND 

Named method wasn't present in library.

STATUS_FACTORY_NOT_FUNCTIONAL 

Named method is not working right.

Definition at line 40 of file SharedLibraryFactory.h.

Constructor & Destructor Documentation

◆ SharedLibraryFactory() [1/2]

yarp::os::SharedLibraryFactory::SharedLibraryFactory ( )
explicit

Constructor for unconfigured factory.

Definition at line 11 of file SharedLibraryFactory.cpp.

◆ SharedLibraryFactory() [2/2]

yarp::os::SharedLibraryFactory::SharedLibraryFactory ( const char *  dll_name,
const char *  fn_name = YARP_NULLPTR 
)

Constructor.

Parameters
dll_namename/path of shared library.
fn_namename of factory method, a symbol within the shared library.

Definition at line 18 of file SharedLibraryFactory.cpp.

◆ ~SharedLibraryFactory()

yarp::os::SharedLibraryFactory::~SharedLibraryFactory ( )
virtual

Destructor.

Definition at line 27 of file SharedLibraryFactory.cpp.

Member Function Documentation

◆ addRef()

int yarp::os::SharedLibraryFactory::addRef ( )

Increment the reference count of this factory.

Returns
the current reference count of this factory, after increment.

Definition at line 114 of file SharedLibraryFactory.cpp.

◆ getApi()

const yarp::os::SharedLibraryClassApi & yarp::os::SharedLibraryFactory::getApi ( ) const

Get the factory API, which has creation/deletion methods.

Returns
the factory API

Definition at line 103 of file SharedLibraryFactory.cpp.

◆ getBaseClassName()

yarp::os::ConstString yarp::os::SharedLibraryFactory::getBaseClassName ( ) const

Get the base type associated with this factory.

Returns
the base type associated with this factory.

Definition at line 136 of file SharedLibraryFactory.cpp.

◆ getClassName()

yarp::os::ConstString yarp::os::SharedLibraryFactory::getClassName ( ) const

Get the type associated with this factory.

Returns
the type associated with this factory.

Definition at line 131 of file SharedLibraryFactory.cpp.

◆ getError()

yarp::os::ConstString yarp::os::SharedLibraryFactory::getError ( ) const

Get the latest error of the factory.

Returns
the latest error.

Definition at line 98 of file SharedLibraryFactory.cpp.

◆ getName()

yarp::os::ConstString yarp::os::SharedLibraryFactory::getName ( ) const

Get the name associated with this factory.

Returns
the name associated with this factory.

Definition at line 126 of file SharedLibraryFactory.cpp.

◆ getReferenceCount()

int yarp::os::SharedLibraryFactory::getReferenceCount ( ) const

Get the current reference count of this factory.

Returns
the current reference count of this factory.

Definition at line 108 of file SharedLibraryFactory.cpp.

◆ getStatus()

int yarp::os::SharedLibraryFactory::getStatus ( ) const

Get the status of the factory.

Returns
one of the SharedLibraryFactory::STATUS_* codes.

Definition at line 93 of file SharedLibraryFactory.cpp.

◆ isValid()

bool yarp::os::SharedLibraryFactory::isValid ( ) const

Check if factory is configured and present.

Returns
true iff factory is good to go.

Definition at line 73 of file SharedLibraryFactory.cpp.

◆ open()

bool yarp::os::SharedLibraryFactory::open ( const char *  dll_name,
const char *  fn_name = YARP_NULLPTR 
)

Configure the factory.

Parameters
dll_namename/path of shared library.
fn_namename of factory method, a symbol within the shared library.
Returns
true on success.

Definition at line 31 of file SharedLibraryFactory.cpp.

◆ removeRef()

int yarp::os::SharedLibraryFactory::removeRef ( )

Decrement the reference count of this factory.

Returns
the current reference count of this factory, after decrement.

Definition at line 120 of file SharedLibraryFactory.cpp.

◆ useFactoryFunction()

bool yarp::os::SharedLibraryFactory::useFactoryFunction ( void *  factory)

Specify function to use as factory.

Parameters
factoryfunction to use as factory.
Returns
true on success.

Definition at line 141 of file SharedLibraryFactory.cpp.

Member Data Documentation

◆ api

SharedLibraryClassApi yarp::os::SharedLibraryFactory::api
private

Definition at line 160 of file SharedLibraryFactory.h.

◆ baseClassName

ConstString yarp::os::SharedLibraryFactory::baseClassName
private

Definition at line 165 of file SharedLibraryFactory.h.

◆ className

ConstString yarp::os::SharedLibraryFactory::className
private

Definition at line 164 of file SharedLibraryFactory.h.

◆ error

ConstString yarp::os::SharedLibraryFactory::error
private

Definition at line 166 of file SharedLibraryFactory.h.

◆ lib

SharedLibrary yarp::os::SharedLibraryFactory::lib
private

Definition at line 158 of file SharedLibraryFactory.h.

◆ name

ConstString yarp::os::SharedLibraryFactory::name
private

Definition at line 163 of file SharedLibraryFactory.h.

◆ rct

int yarp::os::SharedLibraryFactory::rct
private

Definition at line 162 of file SharedLibraryFactory.h.

◆ returnValue

int yarp::os::SharedLibraryFactory::returnValue
private

Definition at line 161 of file SharedLibraryFactory.h.

◆ status

int yarp::os::SharedLibraryFactory::status
private

Definition at line 159 of file SharedLibraryFactory.h.


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