C++ - class Inheritance

C++ Class Inheritance

  • LocalDataBaseImpl
// FeatureHandlerBase.h
class FeatureHandlerBase
{
public:
  virtual void setFeatureGenericResponsible(FeatureGenericResponsible* featureResponsible) = 0;
}

//TackHandler.h
class TaskHandler: public FeatureHandlerBase
{
    // Parent Class : FeatureHandlerBase
    // Child Class : TaskHandler
  void setFeatureGenericResponsible(FeatureGenericResponsible* featureResponsible) override;
}

// TaskHandler.cc
void TaskHandler::setFeatureGenericResponsible(FeatureGenericResponsible* featureResponsible)
{
  m_featureResponsible = featureResponsible; // featureResponsible will be set as LocalDataBaseImpl
  m_LocalDataData = m_featureResponsible->getData();
}

// LocalDataBaseImpl.h
class LocalDataBaseImpl: public LocalData,
                         public FeatureGenericResponsible,
{
    // Parent Class : LocalData, FeatureGenericResponsible
    // Child Class : LocalDataBaseImpl
}

// LocalDataBaseImpl.cc
void LocalDataBaseImpl::initFeatureHandler(void)
{
  FeatureHandlerBase* taskHandler = new TaskHandler(); // create TaskHandler object
  taskHandler->setFeatureGenericResponsible(static_cast<FeatureGenericResponsible*>(this)); // this : LocalDataBaseImpl object
  m_featureHandlerMap.insert(std::pair<FeatureTypeE, FeatureHandlerBase*>(FEAT_TYPE_AAA, taskHandler));
}

virtual function

  • A virtual function allows derived classes to replace the implementation provided by the base class.

static_case(obj)

Change Object type

this

  • The this pointer holds the address of current object

RPC Message procedure

Remote Procedure Call - Stateful Continue reading

PubSub architecture

Published on August 10, 2023

RESTful architecture

Published on August 09, 2023