creaContours_lib
PrefixMaxKeyGenerator Class Reference

#include <PrefixMaxKeyGenerator.h>

Public Member Functions

 PrefixMaxKeyGenerator ()
 
 ~PrefixMaxKeyGenerator ()
 
bool addKeyThing (std::string theName, std::string thePrefix, int theMax=0)
 
void removeKeyThing (std::string theName)
 
bool existsKeyThing (std::string theName)
 
void updateMaxTo (std::string theName, int posibleMax)
 
bool generateKeyOf (std::string theName, std::string &theInputString)
 
bool generateKeyOf (std::string theName, int posibleMax, std::string &theInputString)
 
bool getPrefixOf (std::string theName, std::string &theInputString)
 
int getCurrentMaxOf (std::string theName)
 
int getTotalThingsNumber ()
 
void clear ()
 

Private Attributes

int numberOfKeyThings
 
std::map< std::string, KeyThingkeyThings
 

Detailed Description

Definition at line 45 of file PrefixMaxKeyGenerator.h.

Constructor & Destructor Documentation

PrefixMaxKeyGenerator::PrefixMaxKeyGenerator ( )

Definition at line 44 of file PrefixMaxKeyGenerator.cxx.

References numberOfKeyThings.

45  {
46  numberOfKeyThings = 0;
47  }
PrefixMaxKeyGenerator::~PrefixMaxKeyGenerator ( )

Definition at line 52 of file PrefixMaxKeyGenerator.cxx.

References clear().

53  {
54  clear();
55  }

Here is the call graph for this function:

Member Function Documentation

bool PrefixMaxKeyGenerator::addKeyThing ( std::string  theName,
std::string  thePrefix,
int  theMax = 0 
)

Definition at line 69 of file PrefixMaxKeyGenerator.cxx.

References keyThings.

Referenced by OutlineModelManager::OutlineModelManager().

70  {
71  KeyThing * kThing = new KeyThing(thePrefix, theMax);
72  int before = keyThings.size();
73  keyThings.insert(std::pair < std::string, KeyThing >( theName, *kThing ));
74  int after = keyThings.size();
75  return after > before;
76  }

Here is the caller graph for this function:

void PrefixMaxKeyGenerator::clear ( )

Definition at line 213 of file PrefixMaxKeyGenerator.cxx.

References keyThings, and numberOfKeyThings.

Referenced by OutlineModelManager::clean(), and ~PrefixMaxKeyGenerator().

214  {
215  std::map<std::string, KeyThing >::iterator iter = keyThings.begin();
216  while( iter != keyThings.end() )
217  {
218  keyThings.erase(iter);
219  }
220  keyThings.clear();
221  numberOfKeyThings = 0;
222  }

Here is the caller graph for this function:

bool PrefixMaxKeyGenerator::existsKeyThing ( std::string  theName)

Definition at line 93 of file PrefixMaxKeyGenerator.cxx.

References keyThings.

94  {
95  return keyThings.find(theName) != keyThings.end();
96  }
bool PrefixMaxKeyGenerator::generateKeyOf ( std::string  theName,
std::string &  theInputString 
)

Definition at line 120 of file PrefixMaxKeyGenerator.cxx.

References KeyThing::getPrefix(), KeyThing::getValue(), and keyThings.

Referenced by OutlineModelManager::addAxe(), OutlineModelManager::addImageSection(), OutlineModelManager::addImageSource(), and OutlineModelManager::addOutline().

121  {
122  theInputString = "";
123  std::map<std::string, KeyThing >::iterator iterP = keyThings.find(theName);
124  if ( iterP != keyThings.end() )
125  {
126  KeyThing kthing = (iterP->second);
127  int max = kthing.getValue();
128  std::ostringstream genKey;
129  genKey<<kthing.getPrefix() << " " << max;
130  theInputString = genKey.str();
131  return true;
132  }
133  return false;
134  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool PrefixMaxKeyGenerator::generateKeyOf ( std::string  theName,
int  posibleMax,
std::string &  theInputString 
)

Definition at line 143 of file PrefixMaxKeyGenerator.cxx.

References KeyThing::getPrefix(), KeyThing::getValue(), keyThings, and KeyThing::setValue().

144  {
145  theInputString = "";
146  std::map<std::string, KeyThing >::iterator iterP = keyThings.find(theName);
147  if ( iterP != keyThings.end() )
148  {
149  KeyThing kthing = (iterP->second);
150  int max = kthing.getValue();
151 
152  if ( max < posibleMax )
153  {
154  kthing.setValue(posibleMax);
155  }
156 
157 
158  std::ostringstream genKey;
159  genKey<<kthing.getPrefix() << " " << kthing.getValue();
160  theInputString = genKey.str();
161  return true;
162  }
163  return false;
164  }

Here is the call graph for this function:

int PrefixMaxKeyGenerator::getCurrentMaxOf ( std::string  theName)

Definition at line 190 of file PrefixMaxKeyGenerator.cxx.

References KeyThing::getValue(), and keyThings.

191  {
192  std::map<std::string, KeyThing >::iterator iterP = keyThings.find(theName);
193  if ( iterP != keyThings.end() )
194  {
195  KeyThing kthing = (iterP->second);
196  return kthing.getValue();
197  }
198  return -1;
199  }

Here is the call graph for this function:

bool PrefixMaxKeyGenerator::getPrefixOf ( std::string  theName,
std::string &  theInputString 
)

Definition at line 172 of file PrefixMaxKeyGenerator.cxx.

References KeyThing::getPrefix(), and keyThings.

173  {
174  theInputString = "";
175  std::map<std::string, KeyThing >::iterator iterP = keyThings.find(theName);
176  if ( iterP != keyThings.end() )
177  {
178  KeyThing kthing = (iterP->second);
179  theInputString = kthing.getPrefix();
180  return true;
181  }
182  return false;
183  }

Here is the call graph for this function:

int PrefixMaxKeyGenerator::getTotalThingsNumber ( )

Definition at line 205 of file PrefixMaxKeyGenerator.cxx.

References keyThings.

206  {
207  return keyThings.size();
208  }
void PrefixMaxKeyGenerator::removeKeyThing ( std::string  theName)

Definition at line 82 of file PrefixMaxKeyGenerator.cxx.

References keyThings.

83  {
84  keyThings.erase(theName);
85  }
void PrefixMaxKeyGenerator::updateMaxTo ( std::string  theName,
int  posibleMax 
)

Definition at line 103 of file PrefixMaxKeyGenerator.cxx.

References keyThings.

104  {
105  std::map<std::string, KeyThing >::iterator iterP = keyThings.find(theName);
106  if ( iterP != keyThings.end() )
107  {
108  int max = (iterP->second).getValue();
109  if ( max < posibleMax )
110  (iterP->second).setValue(posibleMax);
111  }
112  }

Member Data Documentation

std::map<std::string,KeyThing> PrefixMaxKeyGenerator::keyThings
private
int PrefixMaxKeyGenerator::numberOfKeyThings
private

Definition at line 150 of file PrefixMaxKeyGenerator.h.

Referenced by clear(), and PrefixMaxKeyGenerator().


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