osg::GraphOp::ParamSet Class Reference

#include <OSGGraphOp.h>

List of all members.

Public Member Functions

 ParamSet (const std::string &params)
bool operator() (const char *name, std::string &val)
bool operator() (const char *name, Real32 &val)
bool operator() (const char *name, UInt16 &val)
bool operator() (const char *name, UInt32 &val)
bool operator() (const char *name, bool &val)
void markUsed (const char *name)
std::string getUnusedParams (void)

Private Types

typedef std::map< std::string,
std::string > 
valuesT
typedef std::map< std::string,
bool > 
usedT

Private Attributes

valuesT _values
usedT _used


Detailed Description

Definition at line 128 of file OSGGraphOp.h.


Member Typedef Documentation

typedef std::map<std::string, std::string> osg::GraphOp::ParamSet::valuesT [private]

Definition at line 148 of file OSGGraphOp.h.

typedef std::map<std::string, bool> osg::GraphOp::ParamSet::usedT [private]

Definition at line 149 of file OSGGraphOp.h.


Constructor & Destructor Documentation

GraphOp::ParamSet::ParamSet ( const std::string &  params  ) 

Definition at line 184 of file OSGGraphOp.cpp.

References _values, and FDEBUG.

00184                                                  :
00185     _values(),
00186     _used()
00187 {
00188     std::string::const_iterator it = params.begin(), end = params.end();
00189     
00190     std::string key, value;
00191     
00192     while(it != end)
00193     {
00194         char c = 0;
00195         
00196         key = "";
00197         value = "";
00198         
00199         // Read key
00200         while(it != end)
00201         {
00202             c = *it++;
00203             
00204             if(c == ' ' || c == '=')
00205                 break;
00206             
00207             key += tolower(c);
00208         }
00209         
00210         // Do we have a value? Read it
00211         if (it != end && c == '=')
00212         {
00213             while(it != end)
00214             {
00215                 c = *it++;
00216 
00217                 if(c == ' ')
00218                     break;
00219 
00220                 value += c;
00221             }           
00222         }
00223 
00224         // Add key, value pair
00225         
00226         FDEBUG(("GraphOp::ParamSet: key='%s', value='%s'\n", key.c_str(),
00227                                                              value.c_str()));
00228 
00229         _values.insert(valuesT::value_type(key, value));
00230 
00231         // Skip to next param
00232 
00233         while(it != end && (*it == ' '));
00234    }
00235 }


Member Function Documentation

bool GraphOp::ParamSet::operator() ( const char *  name,
std::string &  val 
)

Definition at line 237 of file OSGGraphOp.cpp.

References _used, and _values.

00238 {
00239     valuesT::iterator it = _values.find(name);
00240     
00241     if(it != _values.end())
00242     {
00243         val = (*it).second;
00244         
00245         _used[name] = true;
00246         
00247         return true;
00248     }
00249     return false;
00250 }

bool GraphOp::ParamSet::operator() ( const char *  name,
Real32 val 
)

Definition at line 252 of file OSGGraphOp.cpp.

References _used, and _values.

00253 {
00254     valuesT::iterator it = _values.find(name);
00255     
00256     if(it != _values.end())
00257     {
00258         const Char8* c = (*it).second.c_str();       
00259         FieldDataTraits<Real32>::getFromString(val, c);
00260         
00261         _used[name] = true;
00262         return true;
00263     }
00264     return false;
00265 }

bool GraphOp::ParamSet::operator() ( const char *  name,
UInt16 val 
)

Definition at line 267 of file OSGGraphOp.cpp.

References _used, and _values.

00268 {
00269     valuesT::iterator it = _values.find(name);
00270     
00271     if(it != _values.end())
00272     {
00273         const Char8* c = (*it).second.c_str();       
00274         FieldDataTraits<UInt16>::getFromString(val, c);
00275         
00276         _used[name] = true;
00277         return true;
00278     }
00279     return false;
00280 }

bool GraphOp::ParamSet::operator() ( const char *  name,
UInt32 val 
)

Definition at line 282 of file OSGGraphOp.cpp.

References _used, and _values.

00283 {
00284     valuesT::iterator it = _values.find(name);
00285     
00286     if(it != _values.end())
00287     {
00288         const Char8* c = (*it).second.c_str();       
00289         FieldDataTraits<UInt32>::getFromString(val, c);
00290         
00291         _used[name] = true;
00292         return true;
00293     }
00294     return false;
00295 }

bool GraphOp::ParamSet::operator() ( const char *  name,
bool &  val 
)

Definition at line 297 of file OSGGraphOp.cpp.

References _used, and _values.

00298 {
00299     valuesT::iterator it = _values.find(name);
00300     
00301     if(it != _values.end())
00302     {
00303         if((*it).second.length() == 0)
00304         {
00305             val = true;
00306         }
00307         else
00308         {
00309             const Char8* c = (*it).second.c_str();       
00310             FieldDataTraits2<bool>::getFromString(val, c);
00311         }
00312         
00313         _used[name] = true;
00314         return true;
00315     }
00316     return false;
00317 }

void GraphOp::ParamSet::markUsed ( const char *  name  ) 

Definition at line 319 of file OSGGraphOp.cpp.

References _used.

00320 {
00321     _used[name] = true;
00322 }

std::string GraphOp::ParamSet::getUnusedParams ( void   ) 

Definition at line 324 of file OSGGraphOp.cpp.

References _used, and _values.

Referenced by osg::VerifyGraphOp::setParams(), osg::VerifyGeoGraphOp::setParams(), osg::StripeGraphOp::setParams(), osg::SplitGraphOp::setParams(), osg::SharePtrGraphOp::setParams(), osg::PruneGraphOp::setParams(), osg::MergeGraphOp::setParams(), osg::MaterialMergeGraphOp::setParams(), osg::MakeTransparentGraphOp::setParams(), and osg::GeoTypeGraphOp::setParams().

00325 {
00326     std::string out;
00327     
00328     for (valuesT::iterator it = _values.begin(); it != _values.end(); ++it)
00329     {
00330         usedT::iterator uit = _used.find((*it).first);
00331         
00332         if(uit == _used.end())
00333         {
00334             if(out.length())
00335                 out += " ";
00336                 
00337             out += (*it).first;
00338         }
00339     }
00340  
00341     return out;   
00342 }


Member Data Documentation

Definition at line 151 of file OSGGraphOp.h.

Referenced by getUnusedParams(), operator()(), and ParamSet().

Definition at line 152 of file OSGGraphOp.h.

Referenced by getUnusedParams(), markUsed(), and operator()().


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

Generated on Mon Mar 17 12:05:31 2008 for OpenSG by  doxygen 1.5.5