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
EntityKindisINVALIDif the
EntityIddoes not reference a entity contained in the database or is notEntityId::all().if the
EntityKindof theEntityIdisINVALID
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
HOSTrelated to a givenHOST, the return will simply be theHOSTitself.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
PARTICIPANTrelated to aPROCESS, the return will be all thePARTICIPANTthat thePROCESScontains.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
DATAWRITERrelated to aUSER, the return will be all theDATAWRITERthat are contained in each of thePARTICIPANTin each of thePROCESSthat theUSERcontains.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
TOPICrelated to aDATAREADER, the return will be theTOPICin which theDATAREADERis 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
HOSTrelated to aPARTICIPANT, the return will be theHOSTin which thePARTICIPANTis 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
HOSTrelated to aDOMAIN, the result will be all theHOSTthat have aPARTICIPANTrunning 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 (
DATAREADERandDATAWRITER), i.e. when asking for all theLOCATORrelated to aTOPIC, the result will be all theLOCATORthat are used by all theDATAREADERandDATAWRITERpresent in theTOPIC.