mirror of
https://github.com/logos-co/logos-cpp-sdk.git
synced 2026-09-02 10:41:15 +00:00
add overloards using cpp types to replace qt ones later
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "logos_api_client.h"
|
||||
#include "logos_api_provider.h"
|
||||
#include "token_manager.h"
|
||||
#include <string>
|
||||
|
||||
LogosAPI::LogosAPI(const QString& module_name, QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -19,6 +20,11 @@ LogosAPI::LogosAPI(const QString& module_name, QObject *parent)
|
||||
qRegisterMetaType<LogosResult>("LogosResult");
|
||||
}
|
||||
|
||||
LogosAPI::LogosAPI(const std::string& module_name, QObject *parent)
|
||||
: LogosAPI(QString::fromStdString(module_name), parent)
|
||||
{
|
||||
}
|
||||
|
||||
LogosAPI::~LogosAPI()
|
||||
{
|
||||
// Provider and client will be automatically deleted as child objects
|
||||
@@ -48,6 +54,11 @@ LogosAPIClient* LogosAPI::getClient(const QString& target_module) const
|
||||
return client;
|
||||
}
|
||||
|
||||
LogosAPIClient* LogosAPI::getClient(const std::string& target_module) const
|
||||
{
|
||||
return getClient(QString::fromStdString(target_module));
|
||||
}
|
||||
|
||||
TokenManager* LogosAPI::getTokenManager() const
|
||||
{
|
||||
return m_token_manager;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QHash>
|
||||
#include <string>
|
||||
#include "logos_types.h"
|
||||
|
||||
class LogosAPIClient;
|
||||
@@ -26,6 +27,17 @@ public:
|
||||
* @param parent Parent QObject
|
||||
*/
|
||||
explicit LogosAPI(const QString& module_name, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Construct a new LogosAPI instance (const char* overload — resolves ambiguity)
|
||||
*/
|
||||
explicit LogosAPI(const char* module_name, QObject *parent = nullptr)
|
||||
: LogosAPI(QString(module_name), parent) {}
|
||||
|
||||
/**
|
||||
* @brief Construct a new LogosAPI instance (std::string overload)
|
||||
*/
|
||||
explicit LogosAPI(const std::string& module_name, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
@@ -45,6 +57,17 @@ public:
|
||||
*/
|
||||
LogosAPIClient* getClient(const QString& target_module) const;
|
||||
|
||||
/**
|
||||
* @brief Get the client instance — const char* overload (resolves ambiguity)
|
||||
*/
|
||||
LogosAPIClient* getClient(const char* target_module) const
|
||||
{ return getClient(QString(target_module)); }
|
||||
|
||||
/**
|
||||
* @brief Get the client instance for communicating with a module (std::string overload)
|
||||
*/
|
||||
LogosAPIClient* getClient(const std::string& target_module) const;
|
||||
|
||||
/**
|
||||
* @brief Get the token manager instance
|
||||
* @return TokenManager* Pointer to the token manager
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "logos_object.h"
|
||||
#include "token_manager.h"
|
||||
#include <QMetaObject>
|
||||
#include <string>
|
||||
|
||||
LogosAPIClient::LogosAPIClient(const QString& module_to_talk_to, const QString& origin_module, TokenManager* token_manager, QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -189,6 +190,13 @@ bool LogosAPIClient::informModuleToken(const QString& authToken, const QString&
|
||||
return m_consumer->informModuleToken(authToken, moduleName, token);
|
||||
}
|
||||
|
||||
bool LogosAPIClient::informModuleToken(const std::string& authToken, const std::string& moduleName, const std::string& token)
|
||||
{
|
||||
return informModuleToken(QString::fromStdString(authToken),
|
||||
QString::fromStdString(moduleName),
|
||||
QString::fromStdString(token));
|
||||
}
|
||||
|
||||
bool LogosAPIClient::informModuleToken_module(const QString& authToken, const QString& originModule, const QString& moduleName, const QString& token)
|
||||
{
|
||||
return m_consumer->informModuleToken_module(authToken, originModule, moduleName, token);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QVariantList>
|
||||
#include <QMap>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "logos_mode.h"
|
||||
|
||||
@@ -112,6 +113,9 @@ public:
|
||||
void onEventResponse(QObject* object, const QString& eventName, const QVariantList& data);
|
||||
|
||||
bool informModuleToken(const QString& authToken, const QString& moduleName, const QString& token);
|
||||
bool informModuleToken(const char* authToken, const char* moduleName, const char* token)
|
||||
{ return informModuleToken(QString(authToken), QString(moduleName), QString(token)); }
|
||||
bool informModuleToken(const std::string& authToken, const std::string& moduleName, const std::string& token);
|
||||
bool informModuleToken_module(const QString& authToken, const QString& originModule, const QString& moduleName, const QString& token);
|
||||
|
||||
TokenManager* getTokenManager() const;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "logos_transport.h"
|
||||
#include "logos_transport_factory.h"
|
||||
#include <QDebug>
|
||||
#include <string>
|
||||
|
||||
LogosAPIProvider::LogosAPIProvider(const QString& module_name, QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -63,6 +64,11 @@ bool LogosAPIProvider::registerObject(const QString& name, QObject* object)
|
||||
return publishProvider(name, m_qtProviderObject);
|
||||
}
|
||||
|
||||
bool LogosAPIProvider::registerObject(const std::string& name, QObject* object)
|
||||
{
|
||||
return registerObject(QString::fromStdString(name), object);
|
||||
}
|
||||
|
||||
// New path: LogosProviderObject* -> ModuleProxy -> transport
|
||||
bool LogosAPIProvider::registerObject(const QString& name, LogosProviderObject* provider)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QVariantList>
|
||||
#include <QMap>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class LogosTransportHost;
|
||||
class LogosObject;
|
||||
@@ -36,6 +37,17 @@ public:
|
||||
*/
|
||||
bool registerObject(const QString& name, QObject* object);
|
||||
|
||||
/**
|
||||
* @brief Register a legacy QObject-based plugin — const char* overload (resolves ambiguity)
|
||||
*/
|
||||
bool registerObject(const char* name, QObject* object)
|
||||
{ return registerObject(QString(name), object); }
|
||||
|
||||
/**
|
||||
* @brief Register a legacy QObject-based plugin (std::string overload).
|
||||
*/
|
||||
bool registerObject(const std::string& name, QObject* object);
|
||||
|
||||
/**
|
||||
* @brief Register a new-API LogosProviderObject plugin.
|
||||
* Wraps directly in ModuleProxy.
|
||||
|
||||
@@ -23,18 +23,33 @@ void TokenManager::saveToken(const QString& key, const QString& token)
|
||||
emit tokenSaved(key);
|
||||
}
|
||||
|
||||
void TokenManager::saveToken(const std::string& key, const std::string& token)
|
||||
{
|
||||
saveToken(QString::fromStdString(key), QString::fromStdString(token));
|
||||
}
|
||||
|
||||
QString TokenManager::getToken(const QString& key) const
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
return m_tokens.value(key, QString());
|
||||
}
|
||||
|
||||
std::string TokenManager::getToken(const std::string& key) const
|
||||
{
|
||||
return getToken(QString::fromStdString(key)).toStdString();
|
||||
}
|
||||
|
||||
bool TokenManager::hasToken(const QString& key) const
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
return m_tokens.contains(key);
|
||||
}
|
||||
|
||||
bool TokenManager::hasToken(const std::string& key) const
|
||||
{
|
||||
return hasToken(QString::fromStdString(key));
|
||||
}
|
||||
|
||||
bool TokenManager::removeToken(const QString& key)
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
@@ -46,6 +61,11 @@ bool TokenManager::removeToken(const QString& key)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TokenManager::removeToken(const std::string& key)
|
||||
{
|
||||
return removeToken(QString::fromStdString(key));
|
||||
}
|
||||
|
||||
void TokenManager::clearAllTokens()
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QString>
|
||||
#include <QHash>
|
||||
#include <QMutex>
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* @brief TokenManager provides a singleton interface for managing authentication tokens
|
||||
@@ -30,6 +31,17 @@ public:
|
||||
*/
|
||||
void saveToken(const QString& key, const QString& token);
|
||||
|
||||
/**
|
||||
* @brief Save a token — const char* overload (resolves ambiguity, delegates to QString)
|
||||
*/
|
||||
void saveToken(const char* key, const char* token)
|
||||
{ saveToken(QString(key), QString(token)); }
|
||||
|
||||
/**
|
||||
* @brief Save a token with the given key (std::string overload)
|
||||
*/
|
||||
void saveToken(const std::string& key, const std::string& token);
|
||||
|
||||
/**
|
||||
* @brief Retrieve a token by key
|
||||
* @param key The identifier for the token
|
||||
@@ -37,6 +49,18 @@ public:
|
||||
*/
|
||||
QString getToken(const QString& key) const;
|
||||
|
||||
/**
|
||||
* @brief Retrieve a token — const char* overload (resolves ambiguity, delegates to QString)
|
||||
*/
|
||||
QString getToken(const char* key) const
|
||||
{ return getToken(QString(key)); }
|
||||
|
||||
/**
|
||||
* @brief Retrieve a token by key (std::string overload)
|
||||
* @return std::string The token value, or empty string if not found
|
||||
*/
|
||||
std::string getToken(const std::string& key) const;
|
||||
|
||||
/**
|
||||
* @brief Check if a token exists for the given key
|
||||
* @param key The identifier to check
|
||||
@@ -44,6 +68,17 @@ public:
|
||||
*/
|
||||
bool hasToken(const QString& key) const;
|
||||
|
||||
/**
|
||||
* @brief hasToken — const char* overload (resolves ambiguity, delegates to QString)
|
||||
*/
|
||||
bool hasToken(const char* key) const
|
||||
{ return hasToken(QString(key)); }
|
||||
|
||||
/**
|
||||
* @brief Check if a token exists for the given key (std::string overload)
|
||||
*/
|
||||
bool hasToken(const std::string& key) const;
|
||||
|
||||
/**
|
||||
* @brief Remove a token by key
|
||||
* @param key The identifier for the token to remove
|
||||
@@ -51,6 +86,17 @@ public:
|
||||
*/
|
||||
bool removeToken(const QString& key);
|
||||
|
||||
/**
|
||||
* @brief removeToken — const char* overload (resolves ambiguity, delegates to QString)
|
||||
*/
|
||||
bool removeToken(const char* key)
|
||||
{ return removeToken(QString(key)); }
|
||||
|
||||
/**
|
||||
* @brief Remove a token by key (std::string overload)
|
||||
*/
|
||||
bool removeToken(const std::string& key);
|
||||
|
||||
/**
|
||||
* @brief Clear all tokens
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user