Project

General

Profile

Actions

Support Request #11618

closed

Receiving name of current filter instance

Added by hidden almost 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Customer:
AUDI
Department:
EF
Requester's Priority:
Normal
Support Level:
2nd Level
Resolution:
Solved Issue
Product Issue Numbers:
Affected Products:
Platform:
Other Linux 64bit
Topic:
ADTF::Common
FAQ Links:

Description

Supportanfrage

I was trying to get the instance name of a filter using the recommend way in
https://support.digitalwerk.net/issues/11254
but unfortunately it did not work. The macro is not resolved. And I get the literal string "$(THIS_OBJECT_NAME)".
I tried this in the constructor and in Init() StageGraphReady.

Any suggestion? complete example how this works?

ADTF version is: 3.6.3 (still not the latest)

Lösung

Getting full Session name (path):

tResult cMyFilter::Init(tInitStage eStage)
{
    RETURN_IF_FAILED(cFilter::Init(eStage));    // Note: Always call the ::Init from your base class (e.g. cQtUIFilter) at the beginning, this case cFilter

    if (eStage == StageGraphReady)
    {
        auto strNameUsingGlobalFunction = get_named_graph_object_full_name(*this);
        LOG_INFO("Instance name: %s", strNameUsingGlobalFunction.GetPtr());
    }

    RETURN_NOERROR;
}

Receiving a short instance name:

Use INamedGraphObject::GetName(...) member function of your filter

Alternate way (but public):

RegisterPropertyVariable("name_property", m_strName);

and set "$(THIS_OBJECT_NAME" for cString property variable m_strName


Related issues

Related to Public Support - Support Request #11254: Basic API questions about Sample Stream, Runner and getting the instance nameClosedActions
Actions #1

Updated by hidden almost 4 years ago

  • Related to Support Request #11254: Basic API questions about Sample Stream, Runner and getting the instance name added
Actions #2

Updated by hidden almost 4 years ago

  • Project changed from Public Support to 11
  • Status changed from New to In Progress
  • Topic set to ADTF::Common
  • Customer set to AUDI
  • Department set to EF
Actions #3

Updated by hidden almost 4 years ago

  • Status changed from In Progress to Customer Feedback Required

Hi Samer,

have a look here:

tResult cMyFilter::Init(tInitStage eStage)
{
    RETURN_IF_FAILED(cFilter::Init(eStage));    // Note: Always call the ::Init from your base class (e.g. cQtUIFilter) at the beginning, this case cFilter

    if (eStage == StageGraphReady)
    {
        auto strNameUsingGlobalFunction = get_named_graph_object_full_name(*this);
        LOG_INFO("Instance name: %s", strNameUsingGlobalFunction.GetPtr());
    }

    RETURN_NOERROR;
}
Actions #4

Updated by hidden almost 4 years ago

Hi Samer,

I think you missed registering the property_variable in your constructor:

RegisterPropertyVariable("name_property", m_strName);

Only then will it be resolved during initialization.

Regards,

Martin

Actions #5

Updated by hidden almost 4 years ago

Hi Florian&Martin,

thanks for the answer! both variants work now.
However, I see a disadvantage in each of them.
- with get_named_graph_object_full_name(*this) I get a very long name, which is not helpful for debug messages
- with the property_variable, I expose a property which can be seen/changed by the user
I would prefer a way, where I get the name of the short-object internally.
For the current time, these ways suffice. The ticket can be closed!

Best Regards,
Samer

Actions #6

Updated by hidden almost 4 years ago

Hi Samer,

- with get_named_graph_object_full_name(*this) I get a very long name, which is not helpful for debug messages

then just use the INamedGraphObject::GetName(...) member function of your filter :-)

- with the property_variable, I expose a property which can be seen/changed by the user

Yes, these macros are actually intended to be used by the user creating a session (by using them in property values) and not for your use-case in the first place.

Regards,

Martin

Actions #9

Updated by hidden almost 4 years ago

  • Status changed from Customer Feedback Required to To Be Closed
  • Resolution set to Solved Issue
  • Platform Other Linux 64bit added
Actions #10

Updated by hidden almost 4 years ago

  • Project changed from 11 to Public Support
  • Subject changed from Failed to Get Filter Name with $(THIS_OBJECT_NAME) to Receiving name of current filter instance
  • Description updated (diff)
  • Private changed from Yes to No
Actions #11

Updated by hidden over 3 years ago

  • Status changed from To Be Closed to Closed
Actions

Also available in: Atom PDF