Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Param.h File Reference

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <typeinfo>
#include <ctime>
#include "Config/Exception.h"

Go to the source code of this file.

Namespaces

namespace  cfg

Classes

class  cfg::Param
 A single parameter stored in a configuration. More...

Functions

template<class T>
const std::type_info & gsDataType (void)
template<class T>
const std::type_info & gsVectorType (void)
template<class T>
void gsDataDelete (void *p)
template<class T>
void gsDataCopyCons (void **dest, const void *src)
template<class T>
void gsDataCopy (void *dest, const void *src)
template<class T>
void gsDataPrint (std::ostream &os, const void *p)
template<class T>
std::ostream & operator<< (std::ostream &os, const std::vector< T > &v)


Function Documentation

template<class T>
void gsDataCopy void *  dest,
const void *  src
[static]
 

Copy data from location src to location dest assuming that dest and src point to objects of type T

Definition at line 124 of file Param.h.

00125     {
00126       T* destc = (T*)dest;
00127       T* srcc  = (T*)src;
00128       (*destc) = (*srcc);
00129     }

template<class T>
void gsDataCopyCons void **  dest,
const void *  src
[static]
 

Construct a new object of type T at location (*dest) given object of same type at location src.

Definition at line 110 of file Param.h.

00111     {
00112       T* srcc = (T*)src;
00113       T* newt = new T(*srcc);
00114       *dest   = (void*)newt;
00115     }

template<class T>
void gsDataDelete void *  p  )  [static]
 

Delete the data pointed to by p assuming its of type T

Definition at line 98 of file Param.h.

00099     {
00100       T* pc = (T*)p; delete pc; 
00101     }

template<class T>
void gsDataPrint std::ostream &  os,
const void *  p
[static]
 

Print the data located at p assuming its of type T

Definition at line 137 of file Param.h.

00138     {
00139       T* pc = (T*)p;
00140       os << (*pc);
00141     }

template<class T>
const std::type_info& gsDataType void   )  [static]
 

Return the type info for data of type T

Definition at line 77 of file Param.h.

00078     {
00079       return typeid(T);
00080     }

template<class T>
const std::type_info& gsVectorType void   )  [static]
 

Params always hold vectors (see Config/xml/paramBuilder.cxx). Return the type info for data of vector type T

Definition at line 87 of file Param.h.

00088     {
00089       return typeid(typename T::value_type);
00090     }

template<class T>
std::ostream& operator<< std::ostream &  os,
const std::vector< T > &  v
[static]
 

Print a vector of basic types

Definition at line 149 of file Param.h.

00150     {
00151       int sz   = v.size();
00152       int szm1 = sz-1;
00153       if ( (typeid(T) == typeid(std::string)) || 
00154            (typeid(T) == typeid(const char*)) ) {
00155         // Add quotes if data is of string type
00156         for (int i=0; i<sz; ++i) {
00157           if (i==szm1) os << "\"" << v[i] << "\"";
00158           else         os << "\"" << v[i] << "\" ";
00159         }
00160       }
00161       else {
00162         // Non-string data gets streamed normally
00163         for (int i=0; i<sz; ++i) {
00164           if (i==szm1) os << v[i];
00165           else         os << v[i] << " ";
00166         }
00167       }
00168       return os;
00169     }


Generated on Sat Nov 21 04:45:34 2009 for NOvA Offline by  doxygen 1.3.9.1