Implementation of the Bridge_Exercise() function as used in the Bridge Pattern. More...
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "helpers/formatstring.h"
#include "Bridge_ILogger.h"
#include "Bridge_Exercise.h"
Go to the source code of this file.
Functions | |
static void | _Bridge_Exercise_Demonstrate_Logging (ILogger *logger, const char *loggerType) |
Helper function to show an example of writing to a logger. | |
void | Bridge_Exercise (void) |
Example of using the Bridge Pattern. | |
Implementation of the Bridge_Exercise() function as used in the Bridge Pattern.
Definition in file Bridge_Exercise.c.
|
static |
Helper function to show an example of writing to a logger.
This is called for all types of loggers, showing how the ILogger interface hides the details of the underlying implementation.
logger | An ILogger instance to log to. |
loggerType | The type of the underlying implementation. |
Definition at line 30 of file Bridge_Exercise.c.
References ILogger::data, formatstring(), ILogger::LogError, ILogger::LogInfo, and ILogger::LogTrace.
Referenced by DesignPatternExamples_cpp::Bridge_Exercise(), and Bridge_Exercise().
void Bridge_Exercise | ( | void | ) |
Example of using the Bridge Pattern.
The Bridge pattern is used to allow a program to offer multiple ways to perform logging without changing how the logging is used throughout the program.
In this exercise, note how the calls into the logger are the same regardless of the logger used.
Definition at line 68 of file Bridge_Exercise.c.
References _Bridge_Exercise_Demonstrate_Logging(), CreateLogger(), DestroyLogger(), LoggerType_ToConsole, LoggerType_ToFile, and LoggerType_ToNull.