Ceylan::Log::ObjectIdentifier Class Reference

This class encapsulates identifiers of Ceylan objects. More...

#include <CeylanObjectIdentifier.h>

Inheritance diagram for Ceylan::Log::ObjectIdentifier:

Inheritance graph
[legend]
Collaboration diagram for Ceylan::Log::ObjectIdentifier:

Collaboration graph
[legend]

List of all members.

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


Detailed Description

This class encapsulates identifiers of Ceylan objects.

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.

See also:
Object, Loggable, LogAggregator

Definition at line 64 of file CeylanObjectIdentifier.h.


Member Enumeration Documentation

Defines what text output formats for TextDisplayable instances are available.

Enumerator:
rawText 
html 

Definition at line 124 of file CeylanTextDisplayable.h.


Constructor & Destructor Documentation

Ceylan::Log::ObjectIdentifier::ObjectIdentifier ( const Object object  )  [explicit]

Generates, from a class name, the corresponding Object identifier.

Parameters:
object the object that is to be identified.
Note:
Use that constructor when object is available.

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.

Parameters:
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.
Note:
Use that constructor when object is not available, such as when being on log aggregator's side.

ObjectIdentifier::~ObjectIdentifier (  )  throw () [virtual]

Basic virtual destructor.

Definition at line 140 of file CeylanObjectIdentifier.cc.


Member Function Documentation

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.

Exceptions:
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.
Note:
Ownership of the identifier is transferred to the caller.
If an exception is raised, no prior ObjectIdentifier has been instanciated, so there will not be memory leaks.

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]

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.

Parameters:
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.

Parameters:
displayables a list of pointers to TextDisplayable instances/
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
toString, Ceylan::VerbosityLevels

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.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
TextDisplayable

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


Member Data Documentation

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

The class name of the referenced object.

Definition at line 199 of file CeylanObjectIdentifier.h.

Referenced by differentButMatches(), ObjectIdentifier(), and toString().

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.

Note:
Defaults to raw text.

Definition at line 158 of file CeylanTextDisplayable.h.

Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().

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 matching all Object identifiers.

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


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

Generated on Thu Jun 4 20:40:23 2009 for Ceylan by  doxygen 1.5.8