Main Page | Class List | File List | Class Members | File Members

PingTargets Class Reference

Contains ping targets and functions for creating and adding PingTarget objects and formatting statistics for all targets. More...

#include <PingTarget.h>

List of all members.

Public Types

typedef std::vector< PingTarget
* >::const_iterator 
const_iterator
enum  LOG_FILENAME_TYPE { LOG_FILENAME_PLAIN, LOG_FILENAME_DAILY, LOG_FILENAME_HOURLY }
 Filename pattern used for PrintLogCurrent. More...

Public Member Functions

 PingTargets ()
 ~PingTargets ()
 Destroys all added targets.
PingTargetAddTarget (const char *name)
 Adds target to container if name resolves to valid AF_INET address and maximum number of targets is not exceeded.
bool AddTargets (std::istream &is)
 Adds targets in stream.
bool AddTargets (const char *pszFilename)
 Adds targets in file.
long GetMaxTargets () const
 Returns the maximum number of targets.
PingTargetGet (long id) const
 Returns pointer to target or NULL.
bool AddResponse (long id, double ms)
 Adds response to target with id.
void ClearResponseFlags ()
 Sets all response flags on contained targets to false.
void AddUnreachableResponses ()
 Adds a unreachable response to alle targets without a response.
long GetTargetId (USHORT sequence) const
 Target id is embedded in the sequence parameter of ICMP header as the upper bits defined by mask m_uIdMask.
long GetSequence (USHORT sequence) const
 Sequence is embedded in the sequence parameter of ICMP header as the lower bits defined by mask m_uSeqMask.
USHORT MakeSequence (long lId, long lSequence) const
 Calculates ICMP sequence based on id and sequence.
long GetMaxSequence () const
 Returns the largest sequence number available.
const_iterator begin () const
const_iterator end () const
size_t size () const
void PrintStatisticsHeader (std::ostream &os, long lConsoleWidth=79) const
 Prints statistics header to stream.
void PrintStatistics (std::ostream &os, long lConsoleWidth=79) const
 Prints statistics to stream.
void PrintLogHeader (std::ostream &os) const
 Prints log file header for a single target to stream.
void PrintLogCurrent (std::ostream &os, const SYSTEMTIME &systemtime) const
 Prints specified time and current ping values to stream as a single line separated by tab character.
bool PrintLogCurrent (const char *pszFilename, const SYSTEMTIME &systemtime, LOG_FILENAME_TYPE FilenameType=LOG_FILENAME_PLAIN, bool bNewFile=false) const
 Prints specified time and current ping values to the specified file as a single line separated by tab character.
long GetMaxNameWidth () const
 Return the longest target name width.

Protected Types

typedef std::vector< PingTarget
* >::iterator 
iterator

Protected Attributes

long m_lIdBits
 High order bits used for ICMP id.
long m_lIdMax
 Largest id available.
long m_lSequenceBits
 Bits used for sequence.
USHORT m_uIdMask
 Mask for id bits only on USHORT value.
USHORT m_uSeqMask
 Mask for sequence bits only on USHORT value.
long m_lSequenceMax
 Largest sequence value.
long m_lMaxNameWidth
 Maximum target name width.
std::vector< PingTarget * > m_targets

Friends

std::ostream & operator<< (std::ostream &os, const PingTargets &targets)


Detailed Description

Contains ping targets and functions for creating and adding PingTarget objects and formatting statistics for all targets.

Definition at line 95 of file PingTarget.h.


Member Typedef Documentation

typedef std::vector<PingTarget*>::const_iterator PingTargets::const_iterator
 

Definition at line 149 of file PingTarget.h.

typedef std::vector<PingTarget*>::iterator PingTargets::iterator [protected]
 

Definition at line 211 of file PingTarget.h.


Member Enumeration Documentation

enum PingTargets::LOG_FILENAME_TYPE
 

Filename pattern used for PrintLogCurrent.

  • LOG_FILENAME_PLAIN uses the specified filename as is.
  • LOG_FILENAME_DAILY uses the specified filename as a pattern:
    filenameYYYYMMDD.ext
    YYYY is the 4 digit year, MM is the month and DD is the date.
  • LOG_FILENAME_HOURLY uses the specified filename as a pattern:
    filenameYYYYMMDD_HH.ext
    YYYY is the 4 digit year, MM is the month, DD is the date and HH is the hour 00-23.
Enumerator:
LOG_FILENAME_PLAIN 
LOG_FILENAME_DAILY 
LOG_FILENAME_HOURLY 

Definition at line 178 of file PingTarget.h.


Constructor & Destructor Documentation

PingTargets::PingTargets  ) 
 

Definition at line 141 of file PingTarget.cpp.

References m_lIdBits, m_lIdMax, m_lMaxNameWidth, m_lSequenceBits, m_lSequenceMax, m_uIdMask, and m_uSeqMask.

PingTargets::~PingTargets  ) 
 

Destroys all added targets.

Definition at line 152 of file PingTarget.cpp.

References begin(), end(), and m_targets.

Here is the call graph for this function:


Member Function Documentation

bool PingTargets::AddResponse long  id,
double  ms
 

Adds response to target with id.

-1 is unreachable or timeout. returns true if id is valid.

Definition at line 233 of file PingTarget.cpp.

References PingTarget::AddResponseTime(), and Get().

Referenced by main().

Here is the call graph for this function:

PingTarget * PingTargets::AddTarget const char *  name  ) 
 

Adds target to container if name resolves to valid AF_INET address and maximum number of targets is not exceeded.

Returns pointer to new target or NULL. Pointer will only be valid as long as the PingTargets instance.

Definition at line 159 of file PingTarget.cpp.

References GetMaxTargets(), m_lIdMax, m_lMaxNameWidth, PingTarget::m_sName, and m_targets.

Referenced by AddTargets(), and main().

Here is the call graph for this function:

bool PingTargets::AddTargets const char *  pszFilename  ) 
 

Adds targets in file.

One target per line. Returns true if all targets were added succesfully.

Definition at line 206 of file PingTarget.cpp.

References AddTargets().

Here is the call graph for this function:

bool PingTargets::AddTargets std::istream &  is  ) 
 

Adds targets in stream.

One target per line. Returns true if all targets were added succesfully.

Definition at line 189 of file PingTarget.cpp.

References AddTarget(), and trim_spaces().

Referenced by AddTargets(), and main().

Here is the call graph for this function:

void PingTargets::AddUnreachableResponses  ) 
 

Adds a unreachable response to alle targets without a response.

Definition at line 250 of file PingTarget.cpp.

References PingTarget::AddResponseTime(), PingTarget::IsResponseAdded(), and m_targets.

Referenced by main().

Here is the call graph for this function:

const_iterator PingTargets::begin  )  const [inline]
 

Definition at line 150 of file PingTarget.h.

References m_targets.

Referenced by main(), operator<<(), PrintLogCurrent(), PrintLogHeader(), PrintStatistics(), and ~PingTargets().

void PingTargets::ClearResponseFlags  ) 
 

Sets all response flags on contained targets to false.

Definition at line 244 of file PingTarget.cpp.

References m_targets.

Referenced by main().

const_iterator PingTargets::end  )  const [inline]
 

Definition at line 151 of file PingTarget.h.

References m_targets.

Referenced by main(), operator<<(), PrintLogCurrent(), PrintLogHeader(), PrintStatistics(), and ~PingTargets().

PingTarget * PingTargets::Get long  id  )  const
 

Returns pointer to target or NULL.

Definition at line 225 of file PingTarget.cpp.

References m_targets, and size().

Referenced by AddResponse().

Here is the call graph for this function:

long PingTargets::GetMaxNameWidth  )  const [inline]
 

Return the longest target name width.

Definition at line 188 of file PingTarget.h.

References m_lMaxNameWidth.

Referenced by PrintStatistics(), and PrintStatisticsHeader().

long PingTargets::GetMaxSequence  )  const [inline]
 

Returns the largest sequence number available.

Definition at line 147 of file PingTarget.h.

References m_lSequenceMax.

Referenced by main().

long PingTargets::GetMaxTargets  )  const
 

Returns the maximum number of targets.

Definition at line 220 of file PingTarget.cpp.

References m_lIdMax.

Referenced by AddTarget().

long PingTargets::GetSequence USHORT  sequence  )  const
 

Sequence is embedded in the sequence parameter of ICMP header as the lower bits defined by mask m_uSeqMask.

Definition at line 265 of file PingTarget.cpp.

References m_uSeqMask.

Referenced by main().

long PingTargets::GetTargetId USHORT  sequence  )  const
 

Target id is embedded in the sequence parameter of ICMP header as the upper bits defined by mask m_uIdMask.

Definition at line 260 of file PingTarget.cpp.

References m_lSequenceBits.

Referenced by main().

USHORT PingTargets::MakeSequence long  lId,
long  lSequence
const
 

Calculates ICMP sequence based on id and sequence.

Definition at line 270 of file PingTarget.cpp.

References m_lSequenceBits.

Referenced by PingTarget::MakeSequence().

bool PingTargets::PrintLogCurrent const char *  pszFilename,
const SYSTEMTIME &  systemtime,
LOG_FILENAME_TYPE  FilenameType = LOG_FILENAME_PLAIN,
bool  bNewFile = false
const
 

Prints specified time and current ping values to the specified file as a single line separated by tab character.

-1 is unreachable or timeout. If bNewFile is true file is truncated otherwise values are appended to the existing file. Header is added if file is truncated or does not exist.

Definition at line 343 of file PingTarget.cpp.

References LOG_FILENAME_DAILY, LOG_FILENAME_HOURLY, LOG_FILENAME_PLAIN, PrintLogCurrent(), and PrintLogHeader().

Here is the call graph for this function:

void PingTargets::PrintLogCurrent std::ostream &  os,
const SYSTEMTIME &  systemtime
const
 

Prints specified time and current ping values to stream as a single line separated by tab character.

-1 is unreachable or timeout.

Definition at line 330 of file PingTarget.cpp.

References begin(), end(), PingTarget::GetCurrent(), and format_system_time::show_seconds.

Referenced by main(), and PrintLogCurrent().

Here is the call graph for this function:

void PingTargets::PrintLogHeader std::ostream &  os  )  const
 

Prints log file header for a single target to stream.

Header is all target names separated by tab character and a leading tab.

Definition at line 319 of file PingTarget.cpp.

References begin(), end(), and PingTarget::GetName().

Referenced by PrintLogCurrent().

Here is the call graph for this function:

void PingTargets::PrintStatistics std::ostream &  os,
long  lConsoleWidth = 79
const
 

Prints statistics to stream.

Definition at line 292 of file PingTarget.cpp.

References begin(), end(), PingTarget::GetAvg(), PingTarget::GetCurrent(), PingTarget::GetMax(), GetMaxNameWidth(), PingTarget::GetMin(), PingTarget::GetName(), PingTarget::GetSkipped(), PingTarget::GetSkippedPercent(), and PingTarget::GetStdDev().

Referenced by main().

Here is the call graph for this function:

void PingTargets::PrintStatisticsHeader std::ostream &  os,
long  lConsoleWidth = 79
const
 

Prints statistics header to stream.

Definition at line 275 of file PingTarget.cpp.

References GetMaxNameWidth().

Referenced by main().

Here is the call graph for this function:

size_t PingTargets::size  )  const [inline]
 

Definition at line 152 of file PingTarget.h.

References m_targets.

Referenced by Get(), and main().


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  os,
const PingTargets targets
[friend]
 

Definition at line 400 of file PingTarget.cpp.


Member Data Documentation

long PingTargets::m_lIdBits [protected]
 

High order bits used for ICMP id.

Value set in constructor. Should be 2 - 14 bit. Default value is 6 bits or 63 possible targets.

Definition at line 197 of file PingTarget.h.

Referenced by PingTargets().

long PingTargets::m_lIdMax [protected]
 

Largest id available.

Calculated on m_lIdBits.

Definition at line 199 of file PingTarget.h.

Referenced by AddTarget(), GetMaxTargets(), and PingTargets().

long PingTargets::m_lMaxNameWidth [protected]
 

Maximum target name width.

Definition at line 209 of file PingTarget.h.

Referenced by AddTarget(), GetMaxNameWidth(), and PingTargets().

long PingTargets::m_lSequenceBits [protected]
 

Bits used for sequence.

Calculated on m_lIdBits.

Definition at line 201 of file PingTarget.h.

Referenced by GetTargetId(), MakeSequence(), and PingTargets().

long PingTargets::m_lSequenceMax [protected]
 

Largest sequence value.

Calculated on m_uSeqMask.

Definition at line 207 of file PingTarget.h.

Referenced by GetMaxSequence(), and PingTargets().

std::vector<PingTarget*> PingTargets::m_targets [protected]
 

Definition at line 212 of file PingTarget.h.

Referenced by AddTarget(), AddUnreachableResponses(), begin(), ClearResponseFlags(), end(), Get(), size(), and ~PingTargets().

USHORT PingTargets::m_uIdMask [protected]
 

Mask for id bits only on USHORT value.

Definition at line 203 of file PingTarget.h.

Referenced by PingTargets().

USHORT PingTargets::m_uSeqMask [protected]
 

Mask for sequence bits only on USHORT value.

Definition at line 205 of file PingTarget.h.

Referenced by GetSequence(), and PingTargets().


The documentation for this class was generated from the following files:
Generated on Sun Jun 26 13:44:07 2005 for pingem by  doxygen 1.4.3