Skip to content

Commit

Permalink
Added "Service" postfix to App::Set/GetRegistry() and Set/GetLogger().
Browse files Browse the repository at this point in the history
Add a comment in IWhatEverService interface declarations that it is required to keep the core decoupled from something.
#134 #137
  • Loading branch information
end2endzone committed Dec 29, 2023
1 parent 12e3be1 commit 5f47674
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/core/ActionProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ namespace shellanything
// If regisrykey is specified, it has priority over value. This is required to allow setting a property to an empty value (a.k.a. value="").
if (!regisrykey.empty())
{
IRegistryService* registry = App::GetInstance().GetRegistry();
IRegistryService* registry = App::GetInstance().GetRegistryService();
if (registry == NULL)
{
SA_LOG(ERROR) << "No Registry service configured for evaluating registrykey expression '" << regisrykey << "'.";
Expand Down
8 changes: 4 additions & 4 deletions src/core/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ namespace shellanything
mClipboard = NULL;
}

void App::SetLogger(ILoggerService* logger)
void App::SetLoggerService(ILoggerService* logger)
{
mLogger = logger;
}

ILoggerService* App::GetLogger()
ILoggerService* App::GetLoggerService()
{
return mLogger;
}

void App::SetRegistry(IRegistryService* instance)
void App::SetRegistryService(IRegistryService* instance)
{
mRegistry = instance;
}

IRegistryService* App::GetRegistry()
IRegistryService* App::GetRegistryService()
{
return mRegistry;
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ namespace shellanything
/// If a logger instance is already set, the caller must properly destroy the old instance.
/// </remarks>
/// <param name="logger">A valid instance of a ILogger.</param>
void SetLogger(ILoggerService* logger);
void SetLoggerService(ILoggerService* logger);

/// <summary>
/// Get the current application logger
/// </summary>
/// <returns>Returns a pointer to an ILogger instance. Returns NULL if no logger is set.</returns>
ILoggerService* GetLogger();
ILoggerService* GetLoggerService();

/// <summary>
/// Set the current application registry service.
Expand All @@ -89,13 +89,13 @@ namespace shellanything
/// If a service instance is already set, the caller must properly destroy the old instance.
/// </remarks>
/// <param name="instance">A valid instance of a the service.</param>
void SetRegistry(IRegistryService* instance);
void SetRegistryService(IRegistryService* instance);

/// <summary>
/// Get the current application registry service.
/// </summary>
/// <returns>Returns a pointer of the instance that is currently set. Returns NULL if no service is set.</returns>
IRegistryService* GetRegistry();
IRegistryService* GetRegistryService();

/// <summary>
/// Set the current application clipboard service.
Expand Down
1 change: 1 addition & 0 deletions src/core/IClipboardService.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace shellanything
{
/// <summary>
/// Abstract clipboard service class.
/// Used to decouple the core from Windows Operating System API.
/// </summary>
class SHELLANYTHING_EXPORT IClipboardService
{
Expand Down
1 change: 1 addition & 0 deletions src/core/ILoggerService.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace shellanything
{
/// <summary>
/// Abstract logger class.
/// Used to decouple the core from the current logging framework.
/// </summary>
class SHELLANYTHING_EXPORT ILoggerService
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/IRegistryService.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
namespace shellanything
{
/// <summary>
/// Abstract registry handling class.
/// Abstract registry service class.
/// Used to decouple the core from Windows Operating System API.
/// </summary>
class SHELLANYTHING_EXPORT IRegistryService
{
Expand All @@ -57,7 +58,6 @@ namespace shellanything

};


} //namespace shellanything

#endif //SA_IREGISTRY_SERVICE_H
2 changes: 1 addition & 1 deletion src/core/LoggerHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace shellanything
LoggerHelper::~LoggerHelper()
{
// Log the streamed content to the actual logger
ILoggerService * logger = App::GetInstance().GetLogger();;
ILoggerService * logger = App::GetInstance().GetLoggerService();;

if (logger)
{
Expand Down
4 changes: 2 additions & 2 deletions src/shellextension/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpRe

// Setup an active logger in ShellAnything's core.
logger_service = new shellanything::GlogLoggerService();
app.SetLogger(logger_service);
app.SetLoggerService(logger_service);

// Setup an active registry service in ShellAnything's core.
registry_service = new shellanything::RegistryService();
app.SetRegistry(registry_service);
app.SetRegistryService(registry_service);

// Setup an active registry service in ShellAnything's core.
clipboard_service = new shellanything::ClipboardService();
Expand Down
4 changes: 2 additions & 2 deletions src/tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ int main(int argc, char** argv)

// Setup an active logger service in ShellAnything's core.
shellanything::ILoggerService* logger_service = new shellanything::GlogLoggerService();
app.SetLogger(logger_service);
app.SetLoggerService(logger_service);

// Setup an active registry service in ShellAnything's core.
shellanything::IRegistryService* registry_service = new shellanything::RegistryService();
app.SetRegistry(registry_service);
app.SetRegistryService(registry_service);

// Setup an active registry service in ShellAnything's core.
shellanything::IClipboardService* clipboard_service = new shellanything::ClipboardService();
Expand Down

0 comments on commit 5f47674

Please sign in to comment.