Develop Biology
The language of life
bio::log::Writer Class Reference

#include <Writer.h>

+ Inheritance diagram for bio::log::Writer:
+ Collaboration diagram for bio::log::Writer:

Public Member Functions

 Writer (Engine *logEngine, Filter logFilter)
 
virtual ~Writer ()
 
 BIO_DISAMBIGUATE_ALL_CLASS_METHODS (physical, Writer) Writer()
 
void ExternalLog (Filter logFilter, Level level, const char *format,...) const
 
EngineGetLogEngine ()
 
const EngineGetLogEngine () const
 
bool HasLogEngine () const
 
virtual void SetLogEngine (Engine *logEngine)
 
- Public Member Functions inherited from bio::physical::Filterable
 Filterable (Filter filter)
 
virtual ~Filterable ()
 
 BIO_DISAMBIGUATE_ALL_CLASS_METHODS (physical, Filterable) Filterable()
 
Filter GetFilter () const
 
virtual void InitializeImplementation (ByteStreams args)
 
virtual Code Reify (Symmetry *symmetry)
 
virtual void SetFilter (Filter filter)
 
virtual SymmetrySpin () const
 
- Public Member Functions inherited from bio::physical::Class< Filterable >
 Class (Filterable *object, Symmetry *symmetry=NULL)
 
virtual ~Class ()
 
virtual WaveAsWave ()
 
virtual const WaveAsWave () const
 
virtual WaveClone () const
 
FilterableConvert (Wave *wave)
 
virtual operator Filterable * ()
 
virtual operator Wave * ()
 
- Public Member Functions inherited from bio::physical::Wave
 Wave (Symmetry *symmetry=NULL)
 
virtual ~Wave ()
 
virtual chemical::AtomAsAtom ()
 
virtual const chemical::AtomAsAtom () const
 
virtual WaveAsWave ()
 
virtual const WaveAsWave () const
 
virtual Code Attenuate (const Wave *other)
 
virtual WaveClone () const
 
virtual WaveDemodulate ()
 
virtual const WaveDemodulate () const
 
virtual Code Disattenuate (const Wave *other)
 
virtual Properties GetProperties () const
 
virtual WaveModulate (Wave *signal)
 
virtual Waveoperator* ()
 
virtual const Waveoperator* () const
 
virtual Waveoperator* (Wave *signal)
 
virtual void operator+ (const Wave *other)
 
virtual void operator- (const Wave *other)
 
virtual void operator| (Symmetry *symmetry)
 
virtual Code Reify (Symmetry *symmetry)
 
virtual SymmetrySpin () const
 
- Public Member Functions inherited from bio::physical::Class< Writer >
 Class (Writer *object, Symmetry *symmetry=NULL)
 
virtual ~Class ()
 
virtual WaveAsWave ()
 
virtual const WaveAsWave () const
 
virtual WaveClone () const
 
Writer * Convert (Wave *wave)
 
virtual operator Wave * ()
 
virtual operator Writer * ()
 

Protected Member Functions

virtual void InitializeImplementation (ByteStreams args)
 
void Log (Level level, const char *format,...) const
 
- Protected Member Functions inherited from bio::VirtualBase
 VirtualBase ()
 
virtual ~VirtualBase ()
 
void Initialize (ByteStream arg1)
 
void Initialize (ByteStream arg1, ByteStream arg2)
 
void Initialize (ByteStream arg1, ByteStream arg2, ByteStream arg3)
 
void Initialize (ByteStreams args)
 
virtual void InitializeImplementation (ByteStreams args)=0
 

Additional Inherited Members

- Static Public Member Functions inherited from bio::physical::Wave
static Properties GetResonanceBetween (const Wave *wave, const Properties &properties)
 
static Properties GetResonanceBetween (const Wave *wave1, const Wave *wave2)
 
static Properties GetResonanceBetween (ConstWaves waves)
 
- Protected Attributes inherited from bio::physical::Filterable
Filter m_filter
 
- Protected Attributes inherited from bio::physical::Class< Filterable >
Filterablem_object
 
- Protected Attributes inherited from bio::physical::Wave
Wavem_signal
 
Symmetrym_symmetry
 
- Protected Attributes inherited from bio::VirtualBase
bool m_hasBeenInitialized
 
- Protected Attributes inherited from bio::physical::Class< Writer >
Writer * m_object
 

Detailed Description

A Writer is a base class for any other object that can write to a log engine. The reason for Writer to be a base class, rather than using a singleton log engine is that some objects may wish to write logs to different files than others or, perhaps some logs should be seen only in console output while others should be saved to a file. This also allows an easy drop-in replacement of log::Engine for specific platforms and apps. The above is accomplished by passing log::Engine as a pointer to all LoggerObjects.

Definition at line 42 of file Writer.h.

Constructor & Destructor Documentation

◆ Writer()

bio::log::Writer::Writer ( Engine logEngine,
Filter  logFilter 
)
Parameters
logEngine
logFilter

Definition at line 31 of file Writer.cpp.

32 :
33 physical::Class< Writer >(this),
34 physical::Filterable(filter::Default()),
35 m_logEngine(NULL)
36{
37
38}
Filter Default()

◆ ~Writer()

bio::log::Writer::~Writer ( )
virtual

Definition at line 52 of file Writer.cpp.

53{
54
55}

Member Function Documentation

◆ BIO_DISAMBIGUATE_ALL_CLASS_METHODS()

bio::log::Writer::BIO_DISAMBIGUATE_ALL_CLASS_METHODS ( physical  ,
Writer   
)

Ensure virtual methods point to Class implementations.

◆ ExternalLog()

void bio::log::Writer::ExternalLog ( Filter  logFilter,
Level  level,
const char *  format,
  ... 
) const

For static callers only. This is a little hacky, but its better than having a static logger

Parameters
logFilter
level
format
...

Definition at line 106 of file Writer.cpp.

112{
113 BIO_SANITIZE(m_logEngine, ,
114 return);
115
116 va_list args;
117 va_start(args,
118 format);
119 m_logEngine->Log(
120 filter,
121 level,
122 format,
123 args
124 );
125 va_end(args);
126}
#define BIO_SANITIZE(test, success, failure)
void Log(Filter filter, Level level, const char *format, va_list args)
Definition: Engine.cpp:50

References BIO_SANITIZE, and bio::log::Engine::Log().

◆ GetLogEngine() [1/2]

Engine * bio::log::Writer::GetLogEngine ( )
Returns
a pointer to the log::Engine used by *this.

Definition at line 62 of file Writer.cpp.

63{
64 return m_logEngine;
65}

◆ GetLogEngine() [2/2]

const Engine * bio::log::Writer::GetLogEngine ( ) const
Returns
a const pointer to the log::Engine used by *this.

Definition at line 67 of file Writer.cpp.

68{
69 return m_logEngine;
70}

◆ HasLogEngine()

bool bio::log::Writer::HasLogEngine ( ) const
Returns
whether or not log::Engine* has been set.

Definition at line 72 of file Writer.cpp.

73{
74 return m_logEngine != NULL;
75}

◆ InitializeImplementation()

void bio::log::Writer::InitializeImplementation ( ByteStreams  args)
protectedvirtual

VirtualBase required method. See that class for details (in common/)

Parameters
args

Reimplemented from bio::physical::Filterable.

Definition at line 128 of file Writer.cpp.

129{
130 if (args.size() == 2)
131 {
132 if (args[1].Is(m_logEngine))
133 {
134 m_logEngine = args[1];
135 }
136 args.pop_back();
137 }
138 if (args.size() == 1 && args[0].Is< Filter >())
139 {
140 Filterable::InitializeImplementation(args);
141 }
142}

◆ Log()

void bio::log::Writer::Log ( Level  level,
const char *  format,
  ... 
) const
protected

In case the above are too restrictive

Parameters
level
format
...

Definition at line 77 of file Writer.cpp.

82{
83
84 BIO_SANITIZE(m_logEngine, ,
85 return);
86
87 //Check if filter is on
90 level
91 ), ,
92 return);
93
94 va_list args;
95 va_start(args,
96 format);
97 m_logEngine->Log(
99 level,
100 format,
101 args
102 );
103 va_end(args);
104}
#define BIO_SANITIZE_AT_SAFETY_LEVEL_2(test, success, failure)
bool FilterPass(Filter filter, Level level) const
Definition: Engine.cpp:108

References BIO_SANITIZE, BIO_SANITIZE_AT_SAFETY_LEVEL_2, bio::log::Engine::FilterPass(), bio::log::Engine::Log(), and bio::physical::Filterable::m_filter.

◆ SetLogEngine()

void bio::log::Writer::SetLogEngine ( Engine logEngine)
virtual

Set the log::Engine* for this. Propagate logEngine to any and all related classes that should receive the change. if *this contains member LoggerObjects, these may be overridden to pass the call along to those objects as well. It should be assumed (and is true for bio classes) that the creation of any Writer within another Writer will have its m_logEngine set by the owner object AND that calling SetLogEngine on an owner object will also call SetLogEngine on all objects owned by it. This is not true for SetFilter, as each class may use a different filter

Parameters
logEngine

Definition at line 57 of file Writer.cpp.

58{
59 m_logEngine = logEngine;
60}

The documentation for this class was generated from the following files: