From 234d525ac7dbfb3dc387a5555ce7ac0023f97ebe Mon Sep 17 00:00:00 2001 From: Narumol Prangnawarat Date: Tue, 19 Nov 2019 15:49:18 +0000 Subject: IVGCVSW-4070 Add CreatedNamedTypeEntity and CreateNamedTypedChildEntity functions with Guid Signed-off-by: Narumol Prangnawarat Change-Id: Ide3c3b0a05830af055b3a2c733af4c1c57c0dbaa --- src/profiling/TimelineUtilityMethods.cpp | 55 ++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'src/profiling/TimelineUtilityMethods.cpp') diff --git a/src/profiling/TimelineUtilityMethods.cpp b/src/profiling/TimelineUtilityMethods.cpp index 8c84aa73e9..c1ae610e49 100644 --- a/src/profiling/TimelineUtilityMethods.cpp +++ b/src/profiling/TimelineUtilityMethods.cpp @@ -51,6 +51,27 @@ ProfilingDynamicGuid TimelineUtilityMethods::CreateNamedTypedEntity(const std::s // Generate dynamic GUID of the entity ProfilingDynamicGuid entityGuid = ProfilingService::Instance().NextGuid(); + CreateNamedTypedEntity(entityGuid, name, type); + + return entityGuid; +} + +void TimelineUtilityMethods::CreateNamedTypedEntity(ProfilingDynamicGuid entityGuid, + const std::string& name, + const std::string& type) +{ + // Check that the entity name is valid + if (name.empty()) + { + throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); + } + + // Check that the entity type is valid + if (type.empty()) + { + throw InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); + } + // Send Entity Binary Packet of the entity to the external profiling service m_SendTimelinePacket.SendTimelineEntityBinaryPacket(entityGuid); @@ -59,8 +80,6 @@ ProfilingDynamicGuid TimelineUtilityMethods::CreateNamedTypedEntity(const std::s // Create type entity and send the relationship of the entity with the given type TypeEntity(entityGuid, type); - - return entityGuid; } ProfilingStaticGuid TimelineUtilityMethods::DeclareLabel(const std::string& labelName) @@ -157,6 +176,38 @@ ProfilingDynamicGuid TimelineUtilityMethods::CreateNamedTypedChildEntity(Profili return childEntityGuid; } +void TimelineUtilityMethods::CreateNamedTypedChildEntity(ProfilingDynamicGuid childEntityGuid, + ProfilingGuid parentEntityGuid, + const std::string& entityName, + const std::string& entityType) +{ + // Check that the entity name is valid + if (entityName.empty()) + { + // The entity name is invalid + throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty"); + } + + // Check that the entity type is valid + if (entityType.empty()) + { + // The entity type is invalid + throw InvalidArgumentException("Invalid entity type, the entity type cannot be empty"); + } + + // Create a named type entity from the given guid, name and type, this call throws in case of error + CreateNamedTypedEntity(childEntityGuid, entityName, entityType); + + // Generate a GUID for the retention link relationship + ProfilingDynamicGuid retentionLinkGuid = ProfilingService::Instance().NextGuid(); + + // Send the new retention link to the external profiling service, this call throws in case of error + m_SendTimelinePacket.SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, + retentionLinkGuid, + parentEntityGuid, + childEntityGuid); +} + ProfilingDynamicGuid TimelineUtilityMethods::RecordEvent(ProfilingGuid entityGuid, ProfilingStaticGuid eventClassGuid) { // Take a timestamp -- cgit v1.2.1