OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimTraceManager.cpp
Go to the documentation of this file.
1 //*****************************************************************************
2 // Copyright (C) 2005 Garrett Potts, all rights reserved.
3 //
4 // License: LGPL
5 //
6 // See LICENSE.txt file in the top level directory for more details.
7 //
8 // Author: Garrett Potts
9 //
10 // DESCRIPTION:
11 // Contains declaration of class ossimTraceManager.
12 //
13 //*****************************************************************************
14 // $Id: ossimTraceManager.cpp 9094 2006-06-13 19:12:40Z dburken $
15 
16 #include <algorithm>
17 
19 #include <ossim/base/ossimTrace.h>
20 #include <ossim/base/ossimRegExp.h>
21 
23 
25 {
26  theInstance = this;
27 }
28 
30 {
31  if(!theInstance)
32  {
34  }
35 
36  return theInstance;
37 }
38 
40 {
41  thePattern = pattern;
42  setTraceFlags(true);
43 }
44 
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 }
79 
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 }
91 
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 }
static ossimTraceManager * instance()
ossimTraceManager()
Protected default constructor.
void addTrace(ossimTrace *traceObj)
std::vector< ossimTrace * > theTraceList
The list of trace objects.
ossimString thePattern
The regular expression pattern like "ossimDynamic|ossimGdal".
void setTracePattern(const ossimString &pattern)
Sets "thePattern" to "pattern", then calls setTraceFlags(true).
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32
ossimString getTraceName() const
Returns "theTraceName" as an ossimString.
Definition: ossimTrace.h:40
void compile(const char *)
void removeTrace(ossimTrace *traceObj)
static ossimTraceManager * theInstance
The instance of this manager.
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
void setTraceFlags(bool flag)
Loops through "theTraceList" and sets any trace object&#39;s enable flag to flag if it matches regular ex...
bool find(const char *)