How to get the class of the object that is inserted into the vector using RTTI in C++

  • Thread starter Thread starter John paul coder
  • Start date Start date
J

John paul coder

Guest
Hi,

My requirement is when executing, need to write the log by getting the class of the object that is inserted into the vector.

Could anyone please provide your thoughts on this?

Below is the code snippet:

class IntegrationMgr
{
private:

std::vector<IIntegration*> m_vectIntegrations;
};

bool IntegrationMgr::PrepareInstall()
{
IIntegration *pInfIntegration = new INFIntegration();
if (pInfIntegration)
{
// Setting values to pInfIntegration

m_vectIntegrations.push_back(pInfIntegration);
}
return true;
}


bool IntegrationMgr::Execute()
{
DWORD dwResult = ERROR_SUCCESS;

try
{
// Loop through all items and execute
for (auto iterator = m_vectIntegrations.begin(); iterator != m_vectIntegrations.end(); ++iterator)
{
dwResult = (*iterator)->Execute();

if (!dwResult)
{
//Here, I Need to write the Log by adding the class (INFIntegration) of the object (pInfIntegration) from the vector (m_vectIntegrations). How to get the INFIntegration class?
return false;
}
else
{
return true;
}
}
}
catch (...)
{
dwResult = ERROR_UNHANDLED_EXCEPTION;
}
}


Regards

Continue reading...
 
Back
Top