1.8. Get entities of a given kind¶
The StatisticsBackend
singleton can be queried about all the entities of a given EntityKind
.
For example, get_entities()
function can be used to retrieve all the HOST
for which statistics are reported.
// Get all hosts
std::vector<EntityId> hosts = StatisticsBackend::get_entities(EntityKind::HOST);
for (EntityId host : hosts)
{
std::cout << "Host ID: " << host << std::endl;
}
This call to get_entities()
is the same as:
StatisticsBackend::get_entities(EntityKind::HOST, EntityId::all());
1.8.1. Get entities of a given kind related to another entity¶
The StatisticsBackend
singleton can be queried about all the entities of a given EntityKind
that are related
to any entity.
For example, get_entities()
function can be used to retrieve all the PARTICIPANT
running on a given
HOST
.
// Get all participants running in a host
std::vector<EntityId> participants = StatisticsBackend::get_entities(EntityKind::PARTICIPANT, host_id);
for (EntityId participant : participants)
{
std::cout << "Participant ID: " << participant << std::endl;
}
get_entities()
throws BadParameter
in the following cases:
if the
EntityKind
isINVALID
if the
EntityId
does not reference a entity contained in the database or is notEntityId::all()
.if the
EntityKind
of theEntityId
isINVALID
This function returns the related entities according to the following table:
|
Host |
User |
Process |
Domain |
Topic |
DomainParticipant |
DataWriter |
DataReader |
Locator |
---|---|---|---|---|---|---|---|---|---|
Host |
Itself |
Contains |
Sub-contains |
By DomainParticipant |
By DomainParticipant |
Sub-contains |
Sub-contains |
Sub-contains |
Sub-contains |
User |
Contained |
Itself |
Contains |
By DomainParticipant |
By DomainParticipant |
Sub-contains |
Sub-contains |
Sub-contains |
By Endpoints |
Process |
Sub-contained |
Contained |
Itself |
By DomainParticipant |
By DomainParticipant |
Contains |
Sub-contains |
Sub-contains |
By Endpoints |
Domain |
By DomainParticipant |
By DomainParticipant |
By DomainParticipant |
Itself |
Contains |
Contains |
Sub-contains |
Sub-contains |
By Endpoints |
Topic |
By DomainParticipant |
By DomainParticipant |
By DomainParticipant |
Contained |
Itself |
By Endpoints |
Contains |
Contains |
By Endpoints |
DomainParticipant |
Sub-contained |
Sub-contained |
Contained |
Contained |
By Endpoints |
Itself |
Contains |
Contains |
By Endpoints |
DataWriter |
Sub-contained |
Sub-contained |
Sub-contained |
Sub-contained |
Contained |
Contained |
Itself |
By topic |
Contains |
DataReader |
Sub-contained |
Sub-contained |
Sub-contained |
Sub-contained |
Contained |
Contained |
By topic |
Itself |
Contains |
Locator |
Sub-contained |
By Endpoints |
By Endpoints |
By Endpoints |
By Endpoints |
By Endpoints |
Contained |
Contained |
Itself |
Itself: Means that the return will only contain the entity by which the query is performed, i.e. when asking for all the
HOST
related to a givenHOST
, the return will simply be theHOST
itself.Contains: The returned entities will be the ones that the entity by which the query is performed contains, i.e. when asking for all the
PARTICIPANT
related to aPROCESS
, the return will be all thePARTICIPANT
that thePROCESS
contains.Sub-contains: The returned entities will be the ones that the entity by which the query is performed sub-contains, i.e. when asking for all the
DATAWRITER
related to aUSER
, the return will be all theDATAWRITER
that are contained in each of thePARTICIPANT
in each of thePROCESS
that theUSER
contains.Contained: The returned entity will be that one in which the entity by which the query is performed is contained, i.e. when asking for all the
TOPIC
related to aDATAREADER
, the return will be theTOPIC
in which theDATAREADER
is contained.Sub-contained: The returned entity will be the one in which the entity by which the query is performed is sub-contained, i.e. when asking for all the
HOST
related to aPARTICIPANT
, the return will be theHOST
in which thePARTICIPANT
is sub-contained.By DomainParticipant: The returned entities will be the ones that are related to the entity by which the query is performed through the DomainParticipant, i.e. when asking for all the
HOST
related to aDOMAIN
, the result will be all theHOST
that have aPARTICIPANT
running on saidDOMAIN
.By Endpoints: The returned entities will be the ones that are related to the entity by which the query is performed through the endpoints (
DATAREADER
andDATAWRITER
), i.e. when asking for all theLOCATOR
related to aTOPIC
, the result will be all theLOCATOR
that are used by all theDATAREADER
andDATAWRITER
present in theTOPIC
.