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>
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 108 of file Param.h.

00109     {
00110       T* destc = (T*)dest;
00111       T* srcc  = (T*)src;
00112       (*destc) = (*srcc);
00113     }

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 94 of file Param.h.

00095     {
00096       T* srcc = (T*)src;
00097       T* newt = new T(*srcc);
00098       *dest   = (void*)newt;
00099     }

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

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

Definition at line 82 of file Param.h.

00083     {
00084       T* pc = (T*)p; delete pc; 
00085     }

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 121 of file Param.h.

00122     {
00123       T* pc = (T*)p;
00124       os << (*pc);
00125     }

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

Return the type info for data of type T

Definition at line 71 of file Param.h.

00072     {
00073       return typeid(T);
00074     }

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

Print a vector of basic types

Definition at line 133 of file Param.h.

00134     {
00135       int sz   = v.size();
00136       int szm1 = sz-1;
00137       if ( (typeid(T) == typeid(std::string)) || 
00138            (typeid(T) == typeid(const char*)) ) {
00139         // Add quotes if data is of string type
00140         for (int i=0; i<sz; ++i) {
00141           if (i==szm1) os << "\"" << v[i] << "\"";
00142           else         os << "\"" << v[i] << "\" ";
00143         }
00144       }
00145       else {
00146         // Non-string data gets streamed normally
00147         for (int i=0; i<sz; ++i) {
00148           if (i==szm1) os << v[i];
00149           else         os << v[i] << " ";
00150         }
00151       }
00152       return os;
00153     }


Generated on Mon Dec 1 02:35:20 2008 for NOvA Offline by  doxygen 1.3.9.1