ONE - On-device Neural Engine
Loading...
Searching...
No Matches
hermes::Source Class Reference

Message Source. More...

#include <Source.h>

Data Structures

struct  Registry
 

Public Types

using Setting = SourceSetting
 

Public Member Functions

bool check (const Severity &s) const
 Check whether a message with a given severity is acceptable or not.
 
virtual void reload (const Config *)
 Update Source with a given configuration.
 
std::unique_ptr< MessageBufferbuffer (const Severity &) const
 

Protected Member Functions

 Source ()
 
virtual ~Source ()
 
void activate (Registry *, MessageBus *)
 
void deactivate (void)
 
Settingsetting (void)
 

Detailed Description

Message Source.

"Source" is the actual interface for users. "Source" accepts log messages from client.

Definition at line 34 of file Source.h.

Member Typedef Documentation

◆ Setting

Definition at line 48 of file Source.h.

Constructor & Destructor Documentation

◆ Source()

hermes::Source::Source ( )
protected

Definition at line 25 of file Source.cpp.

26{
27 assert(_reg == nullptr);
28 assert(_bus == nullptr);
29}

◆ ~Source()

hermes::Source::~Source ( )
protectedvirtual

Definition at line 31 of file Source.cpp.

32{
33 assert(_bus == nullptr);
34 assert(_reg == nullptr);
35}

Member Function Documentation

◆ activate()

void hermes::Source::activate ( Registry reg,
MessageBus bus 
)
protected

Definition at line 37 of file Source.cpp.

38{
39 assert((_reg == nullptr) && (_bus == nullptr));
40
41 _reg = reg;
42 _bus = bus;
43
44 _reg->attach(this);
45
46 assert((_bus != nullptr) && (_reg != nullptr));
47}
virtual void attach(Source *)=0

References hermes::Source::Registry::attach().

Referenced by circlechef::Logger::Logger(), exo::Logger::Logger(), luci::Logger::Logger(), moco::Logger::Logger(), and tflchef::Logger::Logger().

◆ buffer()

std::unique_ptr< MessageBuffer > hermes::Source::buffer ( const Severity severity) const

Definition at line 63 of file Source.cpp.

64{
65 return std::make_unique<MessageBuffer>(_bus, severity.category());
66}

References hermes::Severity::category().

◆ check()

bool hermes::Source::check ( const Severity s) const
inline

Check whether a message with a given severity is acceptable or not.

NOTE This routine is performance critical as app always invokes this routine (even when logging is disabled).

Definition at line 70 of file Source.h.

71 {
72 return static_cast<int32_t>(s.level()) < _setting.limit(s.category()).level();
73 }
Limit limit(const SeverityCategory &cat) const

References hermes::SourceSetting::limit().

◆ deactivate()

void hermes::Source::deactivate ( void  )
protected

Definition at line 49 of file Source.cpp.

50{
51 assert((_bus != nullptr) && (_reg != nullptr));
52
53 _reg->detach(this);
54
55 _bus = nullptr;
56 _reg = nullptr;
57
58 assert((_reg == nullptr) && (_bus == nullptr));
59}
virtual void detach(Source *)=0

References hermes::Source::Registry::detach().

Referenced by circlechef::Logger::~Logger(), exo::Logger::~Logger(), luci::Logger::~Logger(), moco::Logger::~Logger(), and tflchef::Logger::~Logger().

◆ reload()

void hermes::Source::reload ( const Config c)
virtual

Update Source with a given configuration.

WARNING Do NOT invoke this manually.

TODO Remove virtual after migration

Definition at line 61 of file Source.cpp.

61{ c->configure(this, _setting); }

References hermes::Config::configure().

◆ setting()

Setting & hermes::Source::setting ( void  )
inlineprotected

Definition at line 60 of file Source.h.

60{ return _setting; }

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