Skip to content

Commit

Permalink
Add default virtual destructors
Browse files Browse the repository at this point in the history
  • Loading branch information
cziter15 committed Feb 15, 2025
1 parent 75d8b36 commit c191ebb
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 40 deletions.
10 changes: 5 additions & 5 deletions src/ksf/comp/ksResetButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ namespace ksf::comps
: pin(pin), triggerState(triggerState), mode(mode)
{}

ksResetButton::~ksResetButton()
{
pinMode(pin, INPUT);
}

bool ksResetButton::init(ksApplication* app)
{
pinMode(pin, mode);
Expand Down Expand Up @@ -69,9 +74,4 @@ namespace ksf::comps

return true;
}

ksResetButton::~ksResetButton()
{
pinMode(pin, INPUT);
}
}
10 changes: 5 additions & 5 deletions src/ksf/comp/ksResetButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ namespace ksf::comps
*/
ksResetButton(uint8_t pin, uint8_t triggerState, uint8_t mode);

/*!
@brief Destructs ksResetButton, restoring INPUT pin state.
*/
virtual ~ksResetButton();

/*!
@brief Initializes the reset button component.
@param app Pointer to the parent ksApplication.
Expand All @@ -63,10 +68,5 @@ namespace ksf::comps
@return Pin number assigned to the reset button.
*/
uint8_t getPin() const { return pin; }

/*!
@brief Destructs ksResetButton, restoring INPUT pin state.
*/
virtual ~ksResetButton();
};
}
10 changes: 5 additions & 5 deletions src/ksf/comp/ksWifiConfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ namespace ksf::comps
deviceName += ksf::getDeviceUuidHex();
}

ksWifiConfigurator::~ksWifiConfigurator()
{
WiFi.softAPdisconnect(true);
}

bool ksWifiConfigurator::init(ksApplication* app)
{
WiFi.softAP(deviceName.c_str());
Expand Down Expand Up @@ -70,9 +75,4 @@ namespace ksf::comps

return !configTimeout.triggered();
}

ksWifiConfigurator::~ksWifiConfigurator()
{
WiFi.softAPdisconnect(true);
}
}
10 changes: 5 additions & 5 deletions src/ksf/comp/ksWifiConfigurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ namespace ksf::comps
*/
ksWifiConfigurator(std::string devicePrefixName);

/*!
@brief Destructs WiFi configurator component.
*/
virtual ~ksWifiConfigurator();

/*!
@brief Handles ksWifiConfigurator logic.
Expand All @@ -72,10 +77,5 @@ namespace ksf::comps
@return True on success, false on fail.
*/
bool postInit(ksApplication* app) override;

/*!
@brief Destructs WiFi configurator component.
*/
virtual ~ksWifiConfigurator();
};
}
10 changes: 5 additions & 5 deletions src/ksf/comp/ksWifiConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ namespace ksf::comps
#endif
}

ksWifiConnector::~ksWifiConnector()
{
WiFi.disconnect(true);
}

void ksWifiConnector::setupMacAddress()
{
#if defined(ESP32)
Expand Down Expand Up @@ -134,9 +139,4 @@ namespace ksf::comps
{
return WiFi.isConnected() && bitflags.gotIpAddress;
}

ksWifiConnector::~ksWifiConnector()
{
WiFi.disconnect(true);
}
}
10 changes: 5 additions & 5 deletions src/ksf/comp/ksWifiConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ namespace ksf::comps
*/
ksWifiConnector(const char* hostname, bool savePower = true);

/*!
@brief Destructos WiFi connector component.
*/
virtual ~ksWifiConnector();

/*!
@brief Initializes WiFi connector component.
@param app Pointer to the parent ksApplication.
Expand All @@ -80,10 +85,5 @@ namespace ksf::comps
@return True if connected. False otherwise.
*/
bool isConnected() const;

/*!
@brief Destructos WiFi connector component.
*/
virtual ~ksWifiConnector();
};
}
2 changes: 2 additions & 0 deletions src/ksf/ksApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace ksf
{
ksApplication::~ksApplication() = default;

bool ksApplication::loop()
{
/* This call will keep millis64 on track (handles rollover). */
Expand Down
4 changes: 4 additions & 0 deletions src/ksf/ksApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ namespace ksf
AppLogCallbackFunc_t appLogCallback; //!< Callback function for logging
#endif
public:
/*!
@brief Destructor.
*/
virtual ~ksApplication();

/*!
@brief Instantiates a component of the type defined by the template instance.
Expand Down
2 changes: 2 additions & 0 deletions src/ksf/ksComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace ksf
{
ksComponent::~ksComponent() = default;

bool ksComponent::init(ksApplication* app)
{
return true;
Expand Down
5 changes: 5 additions & 0 deletions src/ksf/ksComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ namespace ksf
ksComponentState::TYPE componentState { ksComponentState::NotInitialized };

public:
/*!
@brief Destructor.
*/
virtual ~ksComponent();

/*!
@brief Initializes component.
@param app Pointer to the parent ksApplication.
Expand Down
5 changes: 5 additions & 0 deletions src/ksf/ksRtti.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ namespace ksf
class ksRtti
{
public:
/*!
@brief Destructor.
*/
virtual ~ksRtti() = default;

/*!
@brief Retrieves type ID of the object.
@return Object type ID.
Expand Down
2 changes: 2 additions & 0 deletions src/ksf/misc/ksCertUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace ksf::misc

return 255;
}

ksCertFingerprint::~ksCertFingerprint() = default;

bool ksCertFingerprint::fingerprintToBytes(const std::string& fingerprint, uint8_t * bytes, uint8_t bytesLen) const
{
Expand Down
5 changes: 5 additions & 0 deletions src/ksf/misc/ksCertUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ namespace ksf::misc
bool fingerprintToBytes(const std::string& fingerprint, uint8_t* bytes, uint8_t bytesLen) const;

public:
/*!
@brief Destructor.
*/
virtual ~ksCertFingerprint();

/*!
@brief Performs certificate fingerprint setup (platform dependent).
@param client Pointer of WiFiClientSecure
Expand Down
10 changes: 5 additions & 5 deletions src/ksf/misc/ksDomainQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ namespace ksf::misc
*/
ksDomainQuery();

/*!
@brief Destructor.
*/
virtual ~ksDomainQuery();

/*!
@brief Constructs a new ksDomainQuery object.
@param dnsServer IP address of the DNS server to use for resolving domain names. By default, KSF_DOMAIN_QUERY_DNS_SERVER is used.
Expand Down Expand Up @@ -91,10 +96,5 @@ namespace ksf::misc
@brief Handles resolver tasks, such as sending queries and receiving responses.
*/
void process();

/*!
@brief Destructor.
*/
virtual ~ksDomainQuery();
};
}
10 changes: 5 additions & 5 deletions src/ksf/misc/ksWSServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ namespace ksf::misc
*/
ksWSServer(uint16_t port);

/*!
@brief Destructs the server, releasing the resources.
*/
virtual ~ksWSServer();

/*!
@brief Returns simple authentication token for WebSocket authentication process.
Expand Down Expand Up @@ -85,10 +90,5 @@ namespace ksf::misc
@param func The message handler function.
*/
void setMessageHandler(ksWsServerMessageFunc_t func);

/*!
@brief Destructs the server, releasing the resources.
*/
virtual ~ksWSServer();
};
}

0 comments on commit c191ebb

Please sign in to comment.