OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ossimTraceManager Class Reference

#include <ossimTraceManager.h>

Public Member Functions

void setTracePattern (const ossimString &pattern)
 Sets "thePattern" to "pattern", then calls setTraceFlags(true). More...
 
void addTrace (ossimTrace *traceObj)
 
void removeTrace (ossimTrace *traceObj)
 

Static Public Member Functions

static ossimTraceManagerinstance ()
 

Protected Member Functions

 ossimTraceManager ()
 Protected default constructor. More...
 

Private Member Functions

void setTraceFlags (bool flag)
 Loops through "theTraceList" and sets any trace object's enable flag to flag if it matches regular expression of "thePattern". More...
 

Private Attributes

ossimString thePattern
 The regular expression pattern like "ossimDynamic|ossimGdal". More...
 
std::vector< ossimTrace * > theTraceList
 The list of trace objects. More...
 

Static Private Attributes

static ossimTraceManagertheInstance = 0
 The instance of this manager. More...
 

Detailed Description

Definition at line 22 of file ossimTraceManager.h.

Constructor & Destructor Documentation

◆ ossimTraceManager()

ossimTraceManager::ossimTraceManager ( )
protected

Protected default constructor.

Definition at line 24 of file ossimTraceManager.cpp.

References theInstance.

Referenced by instance().

25 {
26  theInstance = this;
27 }
static ossimTraceManager * theInstance
The instance of this manager.

Member Function Documentation

◆ addTrace()

void ossimTraceManager::addTrace ( ossimTrace traceObj)
Parameters
traceObjossimTrace* to add to "theTraceList".

Definition at line 45 of file ossimTraceManager.cpp.

References ossimString::c_str(), ossimRegExp::compile(), ossimRegExp::find(), ossimTrace::getTraceName(), ossimTrace::setTraceFlag(), ossimString::size(), thePattern, and theTraceList.

Referenced by ossimTrace::ossimTrace().

46 {
47  if(!traceObj)
48  {
49  return;
50  }
51 
52  std::vector<ossimTrace*>::iterator iter = std::find(theTraceList.begin(),
53  theTraceList.end(),
54  traceObj);
55  if(iter == theTraceList.end())
56  {
57  theTraceList.push_back(traceObj);
58 
59  if(thePattern.size())
60  {
61  ossimRegExp rxp;
62  rxp.compile(thePattern.c_str());
63  if(rxp.find(traceObj->getTraceName().c_str()))
64  {
65  // Found a match so set the flag and increment the counter.
66  traceObj->setTraceFlag(true);
67  }
68  else
69  {
70  traceObj->setTraceFlag(false);
71  }
72  }
73  else
74  {
75  traceObj->setTraceFlag(false);
76  }
77  }
78 }
std::vector< ossimTrace * > theTraceList
The list of trace objects.
ossimString thePattern
The regular expression pattern like "ossimDynamic|ossimGdal".
std::string::size_type size() const
Definition: ossimString.h:405
ossimString getTraceName() const
Returns "theTraceName" as an ossimString.
Definition: ossimTrace.h:40
void compile(const char *)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
void setTraceFlag(bool flag)
Sets "theEnabled" flag.
Definition: ossimTrace.h:48
bool find(const char *)

◆ instance()

ossimTraceManager * ossimTraceManager::instance ( )
static
Returns
ossimTraceManager* to instance of the ossim trace manager.

Definition at line 29 of file ossimTraceManager.cpp.

References ossimTraceManager(), and theInstance.

Referenced by ossimTrace::ossimTrace(), and ossimTrace::~ossimTrace().

30 {
31  if(!theInstance)
32  {
34  }
35 
36  return theInstance;
37 }
ossimTraceManager()
Protected default constructor.
static ossimTraceManager * theInstance
The instance of this manager.

◆ removeTrace()

void ossimTraceManager::removeTrace ( ossimTrace traceObj)
Parameters
traceObjossimTrace* to remove from "theTraceList".

Definition at line 80 of file ossimTraceManager.cpp.

References theTraceList.

Referenced by ossimTrace::~ossimTrace().

81 {
82  std::vector<ossimTrace*>::iterator iter = std::find(theTraceList.begin(),
83  theTraceList.end(),
84  traceObj);
85 
86  if(iter != theTraceList.end())
87  {
88  theTraceList.erase(iter);
89  }
90 }
std::vector< ossimTrace * > theTraceList
The list of trace objects.

◆ setTraceFlags()

void ossimTraceManager::setTraceFlags ( bool  flag)
private

Loops through "theTraceList" and sets any trace object's enable flag to flag if it matches regular expression of "thePattern".

For trace objects not matching "thePattern" no action is taken.

Definition at line 92 of file ossimTraceManager.cpp.

References ossimString::c_str(), ossimRegExp::compile(), ossimRegExp::find(), thePattern, and theTraceList.

Referenced by setTracePattern().

93 {
94  ossimRegExp rxp;
95  rxp.compile(thePattern.c_str());
96 
97  for(ossim_uint32 idx = 0; idx < theTraceList.size(); ++idx)
98  {
99  if (rxp.find(theTraceList[idx]->getTraceName().c_str()))
100  {
101  // Found a match so set the flag and increment the counter.
102  theTraceList[idx]->setTraceFlag(flag);
103  }
104  }
105 }
std::vector< ossimTrace * > theTraceList
The list of trace objects.
ossimString thePattern
The regular expression pattern like "ossimDynamic|ossimGdal".
unsigned int ossim_uint32
void compile(const char *)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
bool find(const char *)

◆ setTracePattern()

void ossimTraceManager::setTracePattern ( const ossimString pattern)

Sets "thePattern" to "pattern", then calls setTraceFlags(true).

Parameters
patternRegular expression to enable trace for.

Definition at line 39 of file ossimTraceManager.cpp.

References setTraceFlags(), and thePattern.

40 {
41  thePattern = pattern;
42  setTraceFlags(true);
43 }
ossimString thePattern
The regular expression pattern like "ossimDynamic|ossimGdal".
void setTraceFlags(bool flag)
Loops through "theTraceList" and sets any trace object&#39;s enable flag to flag if it matches regular ex...

Member Data Documentation

◆ theInstance

ossimTraceManager * ossimTraceManager::theInstance = 0
staticprivate

The instance of this manager.

Definition at line 60 of file ossimTraceManager.h.

Referenced by instance(), and ossimTraceManager().

◆ thePattern

ossimString ossimTraceManager::thePattern
private

The regular expression pattern like "ossimDynamic|ossimGdal".

Definition at line 63 of file ossimTraceManager.h.

Referenced by addTrace(), setTraceFlags(), and setTracePattern().

◆ theTraceList

std::vector<ossimTrace*> ossimTraceManager::theTraceList
private

The list of trace objects.

Definition at line 66 of file ossimTraceManager.h.

Referenced by addTrace(), removeTrace(), and setTraceFlags().


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