Design Pattern Examples
Overview of object-oriented design patterns
Bridge_ILogger.c File Reference

Implementation of the CreateLogger() and DestroyLogger() functions used in the Bridge Pattern. More...

#include <stdlib.h>
#include "Bridge_FileLogger.h"
#include "Bridge_ConsoleLogger.h"
#include "Bridge_NullLogger.h"
#include "Bridge_ILogger.h"
Include dependency graph for Bridge_ILogger.c:

Go to the source code of this file.

Functions

ILoggerCreateLogger (LoggerTypes loggerType, const char *filename)
 Return an interface for the specified logger.
 
void DestroyLogger (ILogger *logger)
 Release any resources associated with the given logger. The given ILogger instance is no longer valid after this function returns.
 

Detailed Description

Implementation of the CreateLogger() and DestroyLogger() functions used in the Bridge Pattern.

Definition in file Bridge_ILogger.c.

Function Documentation

◆ CreateLogger()

ILogger * CreateLogger ( LoggerTypes  loggerType,
const char *  filename 
)

Return an interface for the specified logger.

Parameters
loggerTypeA value from the LoggerTypes enumeration specifying the type of logger to create.
filenameFor LoggerType_ToFile, this is the path and name of the log file to write to. Ignored for other logger types.
Returns
Returns an ILogger instance that is to be used to log messages. Returns NULL if the logger type is not recognized.

Definition at line 19 of file Bridge_ILogger.c.

References CreateConsoleLogger(), CreateFileLogger(), CreateNullLogger(), ILogger::loggerType, LoggerType_ToConsole, LoggerType_ToFile, and LoggerType_ToNull.

Referenced by Bridge_Exercise().

◆ DestroyLogger()

void DestroyLogger ( ILogger logger)

Release any resources associated with the given logger. The given ILogger instance is no longer valid after this function returns.

Parameters
loggerAn ILogger object representing a logger to be destroyed.

Definition at line 52 of file Bridge_ILogger.c.

References DestroyConsoleLogger(), DestroyFileLogger(), DestroyNullLogger(), ILogger::loggerType, LoggerType_ToConsole, LoggerType_ToFile, and LoggerType_ToNull.

Referenced by Bridge_Exercise().