VSM C++ SDK
Vehicle Specific Modules SDK
ugcs::vsm::Service_discovery_processor Class Reference
Inheritance diagram for ugcs::vsm::Service_discovery_processor:
ugcs::vsm::Request_context< is_processor > ugcs::vsm::Request_container

Public Types

typedef std::shared_ptr< Service_discovery_processorPtr
 Pointer type.
 
typedef std::weak_ptr< Service_discovery_processorWeak_ptr
 Pointer type.
 
typedef Callback_proxy< void, std::string, std::string, std::string, std::string, bool > Detection_handler
 Detector function. More...
 
- Public Types inherited from ugcs::vsm::Request_context< is_processor >
typedef std::shared_ptr< Request_contextPtr
 Pointer type.
 
typedef std::weak_ptr< Request_contextWeak_ptr
 Pointer type.
 
- Public Types inherited from ugcs::vsm::Request_container
enum  Type {
  Type::NONE = 0x0, Type::PROCESSOR = 0x1, Type::COMPLETION_CONTEXT = 0x2, Type::ANY = PROCESSOR | COMPLETION_CONTEXT,
  Type::TEMPORAL = 0x4, Type::TEMP_COMPLETION_CONTEXT = COMPLETION_CONTEXT | TEMPORAL
}
 Container type. More...
 
typedef std::shared_ptr< Request_containerPtr
 Pointer type.
 
typedef std::weak_ptr< Request_containerWeak_ptr
 Pointer type.
 

Public Member Functions

 Service_discovery_processor (Socket_address::Ptr muticast_adress=Socket_address::Create(DEFAULT_DISCOVERY_ADDRESS, DEFAULT_DISCOVERY_PORT))
 
template<class __Callable , typename... __Args>
 __DEFINE_CALLBACK_BUILDER_BODY (Make_detection_handler,(std::string, std::string, std::string, std::string, bool),("","","","", true))
 Builder for detection handler. More...
 
void Advertise_service (const std::string &type, const std::string &name, const std::string &location)
 Sends out the NOTIFY ssdp:alive on all available interfaces. More...
 
void Unadvertise_service (const std::string &type, const std::string &name, const std::string &location)
 Sends out the NOTIFY ssdp:byebye on all available interfaces. More...
 
void Subscribe_for_service (const std::string &type, Detection_handler handler, Request_processor::Ptr context)
 Sends out the M-SEARCH on all available interfaces. More...
 
void Search_for_service (const std::string &type)
 Sends out the M-SEARCH on all available interfaces. More...
 
void Unsubscribe_from_service (const std::string &type)
 Remove service type from subscription list. More...
 
- Public Member Functions inherited from ugcs::vsm::Request_context< is_processor >
virtual Type Get_type () const override
 Get this container type. More...
 
- Public Member Functions inherited from ugcs::vsm::Request_container
 Request_container (const std::string &name, Request_waiter::Ptr waiter=Request_waiter::Create())
 Create container with default associated waiter. More...
 
bool Check_type (Type mask)
 Check if the container type conforms the specified characteristic mask. More...
 
void Submit_request (Request::Ptr request)
 Submit request to this container for further processing or notification handlers invocation. More...
 
void Submit_request_locked (Request::Ptr request, Request_waiter::Locker locker)
 The same as Submit_request, but with previously acquired lock of the associated waiter. More...
 
int Process_requests (int requests_limit=0)
 Process all currently queued requests. More...
 
int Process_requests (std::unique_lock< std::mutex > &lock, int requests_limit=0)
 Process all currently queued requests. More...
 
void Set_waiter (Request_waiter::Ptr waiter)
 Set request waiter associated with this container. More...
 
Request_waiter::Ptr Get_waiter () const
 Get request waiter associated with this container. More...
 
const std::string & Get_name ()
 Get the name of the container. More...
 
void Enable ()
 Enable the container. More...
 
void Disable ()
 Disable the container. More...
 
bool Is_enabled () const
 Check if the container is currently enabled. More...
 

Static Public Member Functions

template<typename... Args>
static Ptr Create (Args &&...args)
 Create an instance. More...
 
template<typename... Args>
static Ptr Get_instance (Args &&...args)
 Get global or create new object instance. More...
 
- Static Public Member Functions inherited from ugcs::vsm::Request_context< is_processor >
template<typename... Args>
static Ptr Create (Args &&...args)
 Create an instance. More...
 
- Static Public Member Functions inherited from ugcs::vsm::Request_container
template<typename... Args>
static Ptr Create (Args &&...args)
 Create an instance. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ugcs::vsm::Request_container
void Processing_loop ()
 Request processing loop implementation. More...
 
void Set_disabled ()
 Disable the container and notify its waiter. More...
 
virtual void On_wait_and_process ()
 Called when default processing loop want to wait for work and process it. More...
 
- Protected Attributes inherited from ugcs::vsm::Request_container
Request_waiter::Ptr waiter
 Waiter associated with this container. More...
 
std::list< Request::Ptrrequest_queue
 Queue of pending requests, i.e. More...
 

Member Typedef Documentation

typedef Callback_proxy<void, std::string, std::string, std::string, std::string, bool> ugcs::vsm::Service_discovery_processor::Detection_handler

Detector function.

User must supply this function via Subscribe_for_service() call. It should follow the signature:

void Handler(string type, string name, string location, string instance_id, bool alive)

Handler parameters:

Parameters
typeservice type
nameservice name
locationlocation uri
instance_idrandom (unique) string which can be used to distinguish services with equal names to prevent multiple connections to the same service via multiple locations.
alivetrue if message is ssdp::alive. false if message is ssdp::byebye.

The Handler will get invoked when NOTIFY or M-SEARCH response is received for given service type.

Member Function Documentation

template<class __Callable , typename... __Args>
ugcs::vsm::Service_discovery_processor::__DEFINE_CALLBACK_BUILDER_BODY ( Make_detection_handler  ,
(std::string, std::string, std::string, std::string, bool)  ,
("","","","", true)   
)

Builder for detection handler.

void ugcs::vsm::Service_discovery_processor::Advertise_service ( const std::string &  type,
const std::string &  name,
const std::string &  location 
)

Sends out the NOTIFY ssdp:alive on all available interfaces.

Responds to M-SEARCH requests for given type.

Parameters
locationCan contain special tag {local_address}, which will be replaced by the address of interface when sending out responses and notifications. Thus user application does not need to know local ip addresses even if dns is not used. Example: "http://{local_address}:12345/my_service/location.point" The broadcasted packet will have 'Location:' header like this: "Location: http://192.168.1.112:12345/my_service/location.point"
template<typename... Args>
static Ptr ugcs::vsm::Service_discovery_processor::Create ( Args &&...  args)
inlinestatic

Create an instance.

template<typename... Args>
static Ptr ugcs::vsm::Service_discovery_processor::Get_instance ( Args &&...  args)
inlinestatic

Get global or create new object instance.

void ugcs::vsm::Service_discovery_processor::Search_for_service ( const std::string &  type)

Sends out the M-SEARCH on all available interfaces.

In order to receive responses Subscribe_for_service() must be called beforehand. Does nothing if there are no active subscriptions.

void ugcs::vsm::Service_discovery_processor::Subscribe_for_service ( const std::string &  type,
Detection_handler  handler,
Request_processor::Ptr  context 
)

Sends out the M-SEARCH on all available interfaces.

Calls handler on each NOTIFY ssdp:alive and M-SEARCH response for given service type. handler must be valid callback until Unsubscribe_from_service() called.

void ugcs::vsm::Service_discovery_processor::Unadvertise_service ( const std::string &  type,
const std::string &  name,
const std::string &  location 
)

Sends out the NOTIFY ssdp:byebye on all available interfaces.

Stop responding to M-SEARCH requests for given type.

void ugcs::vsm::Service_discovery_processor::Unsubscribe_from_service ( const std::string &  type)

Remove service type from subscription list.

Detection handlers will not be called for this service type.


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