#include <CeylanObjectIdentifier.h>
Public Types | |
enum | TextOutputFormat { rawText, html } |
Defines what text output formats for TextDisplayable instances are available. More... | |
Public Member Functions | |
ObjectIdentifier (const Object &object) | |
Generates, from a class name, the corresponding Object identifier. | |
ObjectIdentifier (const std::string &hostname, Ceylan::System::Pid pid, const std::string &className, const void *address) | |
Constructs an Object identifier by specifying its content. | |
virtual | ~ObjectIdentifier () throw () |
Basic virtual destructor. | |
virtual bool | differentButMatches (const ObjectIdentifier &otherID) const |
Tells whether this Object identifier only differs from the specified one because of the class name. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const |
Returns a user-friendly description of the state of this object. | |
bool | operator== (const TextIdentifier &otherIdentifier) |
Compares two text identifiers. | |
Static Public Member Functions | |
static ObjectIdentifier & | generateFromChannelName (const std::string &channelName) |
Generates the object identifier from specified channel name: converts a channel name, which can be found for instance carried by a log message, to an object identifier. | |
static const std::string | ToString (std::list< TextDisplayable * > displayables, Ceylan::VerbosityLevels level=Ceylan::high) |
Returns a user-friendly description of this list of pointers to text displayable instances. | |
static TextOutputFormat | GetOutputFormat () |
Returns the current overall text format to be used by TextDisplayable instances. | |
static void | SetOutputFormat (TextOutputFormat newOutputFormat) |
Sets the current overall text format to be used by TextDisplayable instances. | |
Static Public Attributes | |
static const char | Separator = '/' |
Separator inside an Object identifier. | |
static const std::string | PIDTag = "PID-" |
Prefix marker in Objet identifier for hosting PID. | |
static const std::string | Pattern |
The pattern matching all Object identifiers. | |
Protected Attributes | |
std::string | _hostname |
The hostname of this identifier. | |
System::Pid | _pid |
The PID of the hosting process of the referenced object. | |
std::string | _className |
The class name of the referenced object. | |
const void * | _address |
The address of the referenced object in process memory space. | |
std::string | _id |
The text identifier itself. | |
Static Protected Attributes | |
static TextOutputFormat | _OutputFormat = rawText |
The text format to be used currently by TextDisplayable instances. |
It is convenient to easily retrieve the subparts of this kind of identifier, and allows smart aggregation, when messages sent from a object constructor, therefore with a wrong class name, are conveyed in their right log channel, thanks to the address matching.
Definition at line 64 of file CeylanObjectIdentifier.h.
enum Ceylan::TextDisplayable::TextOutputFormat [inherited] |
Defines what text output formats for TextDisplayable instances are available.
Definition at line 124 of file CeylanTextDisplayable.h.
Ceylan::Log::ObjectIdentifier::ObjectIdentifier | ( | const Object & | object | ) | [explicit] |
Generates, from a class name, the corresponding Object identifier.
object | the object that is to be identified. |
Definition at line 79 of file CeylanObjectIdentifier.cc.
References _address, _className, _hostname, _pid, CEYLAN_LOG, dataUtils::e, Ceylan::System::Process::GetHostingPID(), Ceylan::Network::getMostPreciseLocalHostName(), toString(), Ceylan::Exception::toString(), and Ceylan::Log::LogPlug::warning().
Referenced by generateFromChannelName().
Ceylan::Log::ObjectIdentifier::ObjectIdentifier | ( | const std::string & | hostname, | |
Ceylan::System::Pid | pid, | |||
const std::string & | className, | |||
const void * | address | |||
) |
Constructs an Object identifier by specifying its content.
hostname | the hostname embedded in this identifier. | |
pid | the PID embedded in this identifier. | |
className | the class name embedded in this identifier. | |
address | the address in memory of the referenced object, embedded in this identifier. |
ObjectIdentifier::~ObjectIdentifier | ( | ) | throw () [virtual] |
bool ObjectIdentifier::differentButMatches | ( | const ObjectIdentifier & | otherID | ) | const [virtual] |
Tells whether this Object identifier only differs from the specified one because of the class name.
If so, one could assume they refer actually to the same Loggable instance, since messages sent from their constructor have a faulty class name (mangled).
A risk of mistake arises with automatic variables, since, as they are allocated on the stack, they can easily be at the same address.
This method is notably used by smart aggregators so that the corresponding messages are classified in the right channels.
Definition at line 149 of file CeylanObjectIdentifier.cc.
References _address, _className, _hostname, _pid, generalUtils::false, and generalUtils::true.
Referenced by Ceylan::Log::LogAggregator::createLoggableChannelFrom().
ObjectIdentifier & ObjectIdentifier::generateFromChannelName | ( | const std::string & | channelName | ) | [static] |
Generates the object identifier from specified channel name: converts a channel name, which can be found for instance carried by a log message, to an object identifier.
IdentifierException | if unable to demangle the channel name, which would probably mean that this channel name does not correspond to the private channel of an object. |
Definition at line 196 of file CeylanObjectIdentifier.cc.
References Ceylan::countChars(), dataUtils::e, Ceylan::Network::isAValidHostName(), ObjectIdentifier(), Separator, Ceylan::split(), Ceylan::stringToAddress(), Ceylan::stringToUnsignedLong(), Ceylan::Exception::toString(), and Ceylan::toString().
Referenced by Ceylan::Log::LogAggregator::createLoggableChannelFrom(), and Ceylan::Log::ObjectChannel::ObjectChannel().
TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat | ( | ) | [static, inherited] |
Returns the current overall text format to be used by TextDisplayable instances.
Definition at line 63 of file CeylanTextDisplayable.cc.
References Ceylan::TextDisplayable::_OutputFormat.
Referenced by Ceylan::formatStringList(), Ceylan::formatStringMap(), Ceylan::XML::XMLMarkup::toString(), Ceylan::Maths::Linear::Vector3::toString(), Ceylan::Maths::Linear::Vector2::toString(), Ceylan::Maths::Linear::Tripoint::toString(), Ceylan::Module::toString(), Ceylan::Maths::Linear::Matrix3::toString(), Ceylan::Maths::Linear::Matrix2::toString(), Ceylan::Maths::Linear::HomogeneousMatrix3::toString(), and Ceylan::Maths::Linear::Bipoint::toString().
bool TextIdentifier::operator== | ( | const TextIdentifier & | otherIdentifier | ) | [inherited] |
Compares two text identifiers.
Definition at line 60 of file CeylanTextIdentifier.cc.
References Ceylan::TextIdentifier::_id.
void TextDisplayable::SetOutputFormat | ( | TextOutputFormat | newOutputFormat | ) | [static, inherited] |
Sets the current overall text format to be used by TextDisplayable instances.
newOutputFormat | the new output format. |
Definition at line 72 of file CeylanTextDisplayable.cc.
References Ceylan::TextDisplayable::_OutputFormat.
Referenced by Ceylan::Log::LogHolder::LogHolder().
const std::string TextDisplayable::ToString | ( | std::list< TextDisplayable * > | displayables, | |
Ceylan::VerbosityLevels | level = Ceylan::high | |||
) | [static, inherited] |
Returns a user-friendly description of this list of pointers to text displayable instances.
displayables | a list of pointers to TextDisplayable instances/ | |
level | the requested verbosity level. |
Definition at line 45 of file CeylanTextDisplayable.cc.
References Ceylan::formatStringList().
const string ObjectIdentifier::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const [virtual] |
Returns a user-friendly description of the state of this object.
level | the requested verbosity level. |
Reimplemented from Ceylan::TextIdentifier.
Definition at line 186 of file CeylanObjectIdentifier.cc.
References _address, _className, _hostname, _pid, PIDTag, and Separator.
Referenced by Ceylan::Log::ObjectChannel::ObjectChannel(), and ObjectIdentifier().
const void* Ceylan::Log::ObjectIdentifier::_address [protected] |
The address of the referenced object in process memory space.
Definition at line 207 of file CeylanObjectIdentifier.h.
Referenced by differentButMatches(), ObjectIdentifier(), and toString().
std::string Ceylan::Log::ObjectIdentifier::_className [protected] |
The class name of the referenced object.
Definition at line 199 of file CeylanObjectIdentifier.h.
Referenced by differentButMatches(), ObjectIdentifier(), and toString().
std::string Ceylan::Log::ObjectIdentifier::_hostname [protected] |
The hostname of this identifier.
Definition at line 191 of file CeylanObjectIdentifier.h.
Referenced by differentButMatches(), ObjectIdentifier(), and toString().
std::string Ceylan::TextIdentifier::_id [protected, inherited] |
The text identifier itself.
Definition at line 97 of file CeylanTextIdentifier.h.
Referenced by Ceylan::TextIdentifier::operator==(), and Ceylan::TextIdentifier::toString().
TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited] |
The text format to be used currently by TextDisplayable instances.
Definition at line 158 of file CeylanTextDisplayable.h.
Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().
System::Pid Ceylan::Log::ObjectIdentifier::_pid [protected] |
The PID of the hosting process of the referenced object.
Definition at line 195 of file CeylanObjectIdentifier.h.
Referenced by differentButMatches(), ObjectIdentifier(), and toString().
const string ObjectIdentifier::Pattern [static] |
Initial value:
"^([0-2]{0,1}[0-9]{0,1}[0-9]{1,1}" "[.]{1,1}){3}([0-2]{0,1}[0-9]{0,1}[0-9]{1,1})$"
The pattern must match for instance "sonata/PID-1444/N6Ceylan6ObjectE/0x8050fd0".
Pattern needs to be chosen.
Definition at line 183 of file CeylanObjectIdentifier.h.
const string ObjectIdentifier::PIDTag = "PID-" [static] |
Prefix marker in Objet identifier for hosting PID.
Definition at line 179 of file CeylanObjectIdentifier.h.
Referenced by toString().
const char ObjectIdentifier::Separator = '/' [static] |
Separator inside an Object identifier.
Definition at line 175 of file CeylanObjectIdentifier.h.
Referenced by Ceylan::Log::LogAggregator::demangle(), generateFromChannelName(), and toString().