ArnLib  4.0.x
Active Registry Network
ArnDiscoverBrowser Class Reference

Browsing for Arn services. More...

#include <ArnDiscover.hpp>

Inheritance diagram for ArnDiscoverBrowser:
Collaboration diagram for ArnDiscoverBrowser:

Public Slots

void browse (bool enable=true)
 Change state of browsing. More...
 
void stopBrowse ()
 Stop browsing. More...
 

Public Member Functions

 ArnDiscoverBrowser (QObject *parent=arnNullptr)
 
bool isBrowsing () const
 Return the status of the browsing. More...
 
void setFilter (ArnDiscover::Type typeFilter)
 Set service discover filter using predefined types. More...
 
void setFilter (const QString &group)
 Set service discover filter using group name. More...
 
- Public Member Functions inherited from ArnDiscoverBrowserB
 ArnDiscoverBrowserB (QObject *parent=arnNullptr)
 
 ~ArnDiscoverBrowserB ()
 
int serviceCount () const
 Return the number of active discover services. More...
 
const ArnDiscoverInfoinfoByIndex (int index)
 Return the discover service info by its index. More...
 
const ArnDiscoverInfoinfoById (int id)
 Return the discover service info by its id. More...
 
const ArnDiscoverInfoinfoByName (const QString &serviceName)
 Return the discover service info by its name. More...
 
int indexToId (int index)
 Return the discover service id by its index. More...
 
int IdToIndex (int id)
 Return the discover service index by its id. More...
 
int serviceNameToId (const QString &name)
 Return the discover service id by its name. More...
 
ArnDiscoverInfo::State defaultStopState () const
 Return the default stop state for this service discover browser. More...
 
void setDefaultStopState (ArnDiscoverInfo::State defaultStopState)
 Set the default stop state for this service discover browser. More...
 
bool goTowardState (int index, ArnDiscoverInfo::State state)
 Command a service to go towards a stop state. More...
 

Additional Inherited Members

- Signals inherited from ArnDiscoverBrowserB
void serviceAdded (int index, const QString &name)
 Indicate service has been added (discovered) More...
 
void serviceRemoved (int index)
 Indicate service has been removed. More...
 
void infoUpdated (int index, ArnDiscoverInfo::State state)
 Indicate service has been updated. More...
 

Detailed Description

Browsing for Arn services.

About Arn Discover

For a more complete example see the project ArnBrowser in DiscoverWindow.hpp and DiscoverWindow.cpp files.

Example usage

// In class declare
ArnDiscoverBrowser* _serviceBrowser;
QListWidget* _serviceTabView;
QLabel* _hostNameValue;
// In class code
_serviceBrowser = new ArnDiscoverBrowser( this);
connect(_serviceBrowser, SIGNAL(serviceAdded(int,QString)),
this, SLOT(onServiceAdded(int,QString)));
connect(_serviceBrowser, SIGNAL(serviceRemoved(int)), this, SLOT(onServiceRemoved(int)));
connect(_serviceBrowser, SIGNAL(infoUpdated(int,ArnDiscoverInfo::State)),
this, SLOT(onInfoUpdated(int,ArnDiscoverInfo::State)));
void XXX::onServiceAdded( int index, QString name)
{
_serviceTabView->insertItem( index, name);
}
void XXX::onServiceRemoved( int index)
{
QListWidgetItem* item = _serviceTabView->takeItem( index);
if (item)
delete item;
}
void XXX::onInfoUpdated( int index, ArnDiscoverInfo::State state)
{
int curIndex = _serviceTabView->currentRow();
if (index != curIndex) return; // The updated info is not for selected row
const ArnDiscoverInfo& info = _serviceBrowser->infoByIndex( curIndex);
_hostNameValue->setText( info.hostName());
}

Definition at line 477 of file ArnDiscover.hpp.

Constructor & Destructor Documentation

◆ ArnDiscoverBrowser()

ArnDiscoverBrowser::ArnDiscoverBrowser ( QObject *  parent = arnNullptr)
explicit

Definition at line 237 of file ArnDiscover.cpp.

Member Function Documentation

◆ browse

void ArnDiscoverBrowser::browse ( bool  enable = true)
inlineslot

Change state of browsing.

When browsing is started, services will be discovered.

Parameters
[in]enableif true browsing is started, otherwise it is stopped
See also
stopBrowse()
serviceAdded()

Definition at line 516 of file ArnDiscover.hpp.

◆ isBrowsing()

bool ArnDiscoverBrowser::isBrowsing ( ) const
inline

Return the status of the browsing.

Return values
trueif browsing is started
See also
browse()

Definition at line 487 of file ArnDiscover.hpp.

◆ setFilter() [1/2]

void ArnDiscoverBrowser::setFilter ( ArnDiscover::Type  typeFilter)
inline

Set service discover filter using predefined types.

When filter is enabled, only services that have the same type is discovered.

Parameters
[in]typeFilter
See also
ArnDiscoverAdvertise::advertiseService()

Definition at line 496 of file ArnDiscover.hpp.

◆ setFilter() [2/2]

void ArnDiscoverBrowser::setFilter ( const QString &  group)
inline

Set service discover filter using group name.

If passing empy group, this is taken as subtype (filter) disabled. When subtype (filter) is enabled, only services that have the same group is discovered.

Parameters
[in]groupthe filter group name, e.g. "myGroup1"
See also
ArnDiscoverAdvertise::setGroups()

Definition at line 506 of file ArnDiscover.hpp.

◆ stopBrowse

void ArnDiscoverBrowser::stopBrowse ( )
inlineslot

Stop browsing.

See also
browse()

Definition at line 522 of file ArnDiscover.hpp.


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