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

Declaration of the ILogger interface, along with the CreateLogger() and DestroyLogger() functions used in the Bridge Pattern. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ILogger
 

Macros

#define __BRIDGE_ILOGGER_H__
 

Enumerations

enum  LoggerTypes { LoggerType_ToNull , LoggerType_ToFile , LoggerType_ToConsole }
 A value passed to CreateLogger() to specify the type of logger to create. More...
 

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

Declaration of the ILogger interface, along with the CreateLogger() and DestroyLogger() functions used in the Bridge Pattern.

Definition in file Bridge_ILogger.h.

Macro Definition Documentation

◆ __BRIDGE_ILOGGER_H__

#define __BRIDGE_ILOGGER_H__

Definition at line 9 of file Bridge_ILogger.h.

Enumeration Type Documentation

◆ LoggerTypes

A value passed to CreateLogger() to specify the type of logger to create.

Enumerator
LoggerType_ToNull 

Log to nowhere, that is, throw out all logging. No additional parameters.

LoggerType_ToFile 

Log to a file. One additional parameter: the name of the file to log to.

LoggerType_ToConsole 

Log to the console. No additional parameters.

Definition at line 14 of file Bridge_ILogger.h.

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().