fipa_services
Public Member Functions | Static Public Member Functions | List of all members
fipa::services::DistributedServiceDirectory Class Reference

Implementation of a distributed service directory using the functionality of Avahi. More...

#include <DistributedServiceDirectory.hpp>

Inheritance diagram for fipa::services::DistributedServiceDirectory:
fipa::services::ServiceDirectory

Public Member Functions

 DistributedServiceDirectory (const std::string &scope=DEFAULT_SERVICE_SCOPE)
 
 DistributedServiceDirectory (const std::vector< std::string > &scopes)
 
virtual ~DistributedServiceDirectory ()
 
void registerService (const ServiceDirectoryEntry &entry)
 
void registerService (const ServiceDirectoryEntry &entry, const std::string &publishDomain, uint32_t ttlInMS=30000)
 
virtual void deregisterService (const std::string &regex, ServiceDirectoryEntry::Field field)
 
ServiceDirectoryList search (const std::string &regex, ServiceDirectoryEntry::Field field, bool doThrow) const
 
- Public Member Functions inherited from fipa::services::ServiceDirectory
 ServiceDirectory ()
 
virtual ~ServiceDirectory ()
 
void deregisterService (const ServiceDirectoryEntry &entry)
 
ServiceDirectoryList search (const ServiceDirectoryEntry &entry) const
 
void modify (const ServiceDirectoryEntry &entry)
 
void updateTimestamp ()
 
base::Time getTimestamp () const
 
ServiceDirectoryList getAll () const
 
virtual void mergeSelectively (const ServiceDirectoryList &updateList, ServiceDirectoryEntry::Field selectiveMerge)
 

Static Public Member Functions

static servicediscovery::avahi::ServiceDescription convert (const ServiceDirectoryEntry &entry)
 
static ServiceDirectoryEntry convert (const servicediscovery::avahi::ServiceDescription &description)
 
static ServiceDirectoryList convert (const std::map< std::string, servicediscovery::avahi::ServiceDescription > &servicesMap)
 

Additional Inherited Members

- Public Types inherited from fipa::services::ServiceDirectory
typedef boost::shared_ptr< ServiceDirectoryPtr
 
- Protected Attributes inherited from fipa::services::ServiceDirectory
boost::mutex mMutex
 

Detailed Description

Implementation of a distributed service directory using the functionality of Avahi.

The distributed service directory allows to register services which are then published in a given avahi domain (default is _fipa_service_directory._udp). Each service can be associated with information on how to access the service. This is done constructing a ServiceLocator object and specifying a service locator.

See also
http://www.fipa.org/specs/fipa00001/SC00001L.html#_Toc26668707
#include <fipa_services/DistributedServiceDirectory.hpp>

using namespace fipa::services;
DistributedServiceDirectory directory;

ServiceLocator locator;
locator.addLocation("tcp://192.168.1.1:2000","agent-signature-type","agent-service-signature");
ServiceDirectoryEntry client("local-agent","type-of-agent",locator, "Description of local-agent");
directory.registerService(client);

fipa::services::ServiceDirectory list = directory.search("other-agent", ServiceDirectoryEntry::NAME, false);

Constructor & Destructor Documentation

fipa::services::DistributedServiceDirectory::DistributedServiceDirectory ( const std::string &  scope = DEFAULT_SERVICE_SCOPE)

Default constructor using the default listening scope for that service discovery

fipa::services::DistributedServiceDirectory::DistributedServiceDirectory ( const std::vector< std::string > &  scopes)

Constructor to allow setting of multiple listening scopes

fipa::services::DistributedServiceDirectory::~DistributedServiceDirectory ( )
virtual

Virtual Destructor

Member Function Documentation

servicediscovery::avahi::ServiceDescription fipa::services::DistributedServiceDirectory::convert ( const ServiceDirectoryEntry entry)
static

Convert a ServiceDirectoryEntry to a avahi description

Parameters
entryServiceDirectoryEntry
Returns
ServiceDescription
ServiceDirectoryEntry fipa::services::DistributedServiceDirectory::convert ( const servicediscovery::avahi::ServiceDescription &  description)
static

Convert an avahi ServiceDescription to a ServiceDirectoryEntry

Parameters
descriptionavahi ServiceDescription
Returns
ServiceDirectoryEntry
ServiceDirectoryList fipa::services::DistributedServiceDirectory::convert ( const std::map< std::string, servicediscovery::avahi::ServiceDescription > &  servicesMap)
static

Convert map of avahi ServiceDescriptions to a ServiceDirectoryList

Parameters
servicesMapMap of avahi ServiceDescriptions
Returns
ServiceDirectoryList
void fipa::services::DistributedServiceDirectory::deregisterService ( const std::string &  regex,
ServiceDirectoryEntry::Field  field 
)
virtual

Looks up services that have been registered with this instance and deregisters them

Exceptions
NotFoundIf the service has not been locally deregistered and thus cannot be deregistered

Reimplemented from fipa::services::ServiceDirectory.

void fipa::services::DistributedServiceDirectory::registerService ( const ServiceDirectoryEntry entry)
inlinevirtual

RegisterService

Reimplemented from fipa::services::ServiceDirectory.

void fipa::services::DistributedServiceDirectory::registerService ( const ServiceDirectoryEntry entry,
const std::string &  publishDomain,
uint32_t  ttlInMS = 30000 
)

Register a service

Parameters
entryThe ServiceDirectoryEntry which describes the service that shall be registered
publishDomainDefault domain under which services will be published
ttlInMSTimeToLive in Milliseconds
ServiceDirectoryList fipa::services::DistributedServiceDirectory::search ( const std::string &  regex,
ServiceDirectoryEntry::Field  field,
bool  doThrow 
) const
virtual

Search for a given service based on the field information

Parameters
regexRegular expression which will be applied to the selected field
fieldField selection which the regex shall be applied on
doThrowIf set to true, the function will throw an exception if no entry could be found

Reimplemented from fipa::services::ServiceDirectory.


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