CMS 3D CMS Logo

IgColumnHandle Class Reference

#include <Iguana/Framework/interface/IgCollection.h>

List of all members.

Public Member Functions

void clear ()
void compress ()
voiddata (void) const
void destroy ()
template<class T>
void doClear (void)
template<class T>
void doCompress (void)
template<class T>
void doExtend ()
template<class T>
void doReserve (unsigned int size)
template<class T>
void doResize (int newSize)
void extend ()
template<class T>
T & get (int index)
 IgColumnHandle (void *data, ColumnType type)
void reserve (unsigned int size)
void resize (unsigned int newSize)
int size (void)
void stream (std::ostream &stream, int position)
void streamType (std::ostream &stream)
ColumnType type (void)

Private Member Functions

template<class T>
void doDestroy (void)

Private Attributes

voidm_data
ColumnType m_type


Detailed Description

Definition at line 150 of file IgCollection.h.


Constructor & Destructor Documentation

IgColumnHandle::IgColumnHandle ( void data,
ColumnType  type 
) [inline]

Definition at line 153 of file IgCollection.h.

00154   :m_data(data), m_type(type)
00155   { }


Member Function Documentation

void IgColumnHandle::clear ( void   )  [inline]

Definition at line 372 of file IgCollection.h.

References DOUBLE_COLUMN, INT_COLUMN, m_type, STRING_COLUMN, VECTOR_2D, VECTOR_3D, and VECTOR_4D.

00373   {
00374     switch (m_type)
00375     {
00376       case INT_COLUMN:
00377         doClear<int>();
00378         break;
00379       case DOUBLE_COLUMN:
00380         doClear<double>();
00381         break;
00382       case STRING_COLUMN:
00383         doClear<std::string>();
00384         break;
00385       case VECTOR_2D:
00386         doClear<IgV2d>();
00387         break;                
00388       case VECTOR_3D:         
00389         doClear<IgV3d>();
00390         break;                
00391       case VECTOR_4D:         
00392         doClear<IgV4d>();
00393         break;
00394       default:
00395         assert(false);
00396         break;
00397     }
00398   }

void IgColumnHandle::compress (  )  [inline]

Definition at line 344 of file IgCollection.h.

References DOUBLE_COLUMN, INT_COLUMN, m_type, STRING_COLUMN, VECTOR_2D, VECTOR_3D, and VECTOR_4D.

00345   {
00346     switch (m_type)
00347     {
00348       case INT_COLUMN:
00349         doCompress<int>();
00350         break;
00351       case DOUBLE_COLUMN:
00352         doCompress<double>();
00353         break;
00354       case STRING_COLUMN:
00355         doCompress<std::string>();
00356         break;
00357       case VECTOR_2D:
00358         doCompress<IgV2d>();
00359         break;                
00360       case VECTOR_3D:         
00361         doCompress<IgV3d>();
00362         break;                
00363       case VECTOR_4D:         
00364         doCompress<IgV4d>();
00365         break;
00366       default:
00367         assert(false);
00368         break;
00369     }
00370   }

void* IgColumnHandle::data ( void   )  const [inline]

Definition at line 160 of file IgCollection.h.

References m_data.

Referenced by doClear(), doCompress(), doDestroy(), doExtend(), doReserve(), doResize(), get(), and IgCollectionItem::moveToColumn().

00161   { return m_data; }

void IgColumnHandle::destroy (  )  [inline]

Definition at line 435 of file IgCollection.h.

References DOUBLE_COLUMN, INT_COLUMN, m_type, STRING_COLUMN, VECTOR_2D, VECTOR_3D, and VECTOR_4D.

00436   {
00437     switch (m_type)
00438     {
00439       case INT_COLUMN:
00440         doDestroy<int>();
00441         break;
00442       case DOUBLE_COLUMN:
00443         doDestroy<double>();
00444         break;
00445       case STRING_COLUMN:
00446         doDestroy<std::string>();
00447         break;
00448       case VECTOR_2D:
00449         doDestroy<IgV2d>();
00450         break;                
00451       case VECTOR_3D:         
00452         doDestroy<IgV3d>();
00453         break;                
00454       case VECTOR_4D:         
00455         doDestroy<IgV4d>();
00456         break;
00457       default:
00458         assert(false);
00459         break;
00460     }
00461   }

template<class T>
void IgColumnHandle::doClear ( void   )  [inline]

Definition at line 422 of file IgCollection.h.

References data(), and m_data.

00423   {
00424     std::vector<T> &data = *(static_cast<std::vector<T> *>(m_data));
00425     data.clear();
00426   }

template<class T>
void IgColumnHandle::doCompress ( void   )  [inline]

Definition at line 415 of file IgCollection.h.

References data(), and m_data.

00416   {
00417     std::vector<T> &data = *(static_cast<std::vector<T> *>(m_data));
00418     data.reserve(data.size());
00419   }

template<class T>
void IgColumnHandle::doDestroy ( void   )  [inline, private]

Definition at line 466 of file IgCollection.h.

References data(), and m_data.

00467   {
00468     std::vector<T> *data = static_cast<std::vector<T> *>(m_data);
00469     data->clear();
00470     delete data;
00471   }

template<class T>
void IgColumnHandle::doExtend (  )  [inline]

Definition at line 401 of file IgCollection.h.

References data(), and m_data.

00402   {
00403     std::vector<T> &data = *(static_cast<std::vector<T> *>(m_data));
00404     data.resize(data.size()+1);
00405   }

template<class T>
void IgColumnHandle::doReserve ( unsigned int  size  )  [inline]

Definition at line 408 of file IgCollection.h.

References data(), and m_data.

00409   {
00410     std::vector<T> &data = *(static_cast<std::vector<T> *>(m_data));
00411     data.reserve(size);
00412   }

template<class T>
void IgColumnHandle::doResize ( int  newSize  )  [inline]

Definition at line 429 of file IgCollection.h.

References data(), and m_data.

00430   {
00431     std::vector<T> &data = *(static_cast<std::vector<T> *>(m_data));
00432         data.resize(newSize);
00433   }

void IgColumnHandle::extend (  )  [inline]

Definition at line 260 of file IgCollection.h.

References DOUBLE_COLUMN, INT_COLUMN, m_type, STRING_COLUMN, VECTOR_2D, VECTOR_3D, and VECTOR_4D.

00261   {
00262     switch (m_type)
00263     {
00264       case INT_COLUMN:
00265         return doExtend<int>();
00266         break;
00267       case DOUBLE_COLUMN:
00268         return doExtend<double>();
00269         break;
00270       case STRING_COLUMN:
00271         return doExtend<std::string>();
00272         break;
00273       case VECTOR_2D:
00274         return doExtend<IgV2d>();
00275         break;                
00276       case VECTOR_3D:         
00277         return doExtend<IgV3d>();
00278         break;                
00279       case VECTOR_4D:         
00280         return doExtend<IgV4d>();
00281         break;
00282       default:
00283         assert(false);
00284         break;
00285     }
00286   }

template<class T>
T& IgColumnHandle::get ( int  index  )  [inline]

Definition at line 164 of file IgCollection.h.

References data(), index, and m_data.

Referenced by IgCollectionItem::current(), IgCollectionItem::get(), IgCollectionItem::operator,(), IgCollectionItem::operator=(), and IgCollectionItem::ContainerTraits< C, T, A >::put().

00165   {
00166     std::vector<T> &data = *(static_cast<std::vector<T> *>(m_data));
00167     return data[index];
00168   }

void IgColumnHandle::reserve ( unsigned int  size  )  [inline]

Definition at line 316 of file IgCollection.h.

References DOUBLE_COLUMN, INT_COLUMN, m_type, STRING_COLUMN, VECTOR_2D, VECTOR_3D, and VECTOR_4D.

00317   {
00318     switch (m_type)
00319     {
00320       case INT_COLUMN:
00321         doReserve<int>(size);
00322         break;
00323       case DOUBLE_COLUMN:
00324         doReserve<double>(size);
00325         break;
00326       case STRING_COLUMN:
00327         doReserve<std::string>(size);
00328         break;
00329       case VECTOR_2D:
00330         doReserve<IgV2d>(size);
00331         break;                
00332       case VECTOR_3D:         
00333         doReserve<IgV3d>(size);
00334         break;                
00335       case VECTOR_4D:         
00336         doReserve<IgV4d>(size);
00337         break;
00338       default:
00339         assert(false);
00340         break;
00341     }
00342   }

void IgColumnHandle::resize ( unsigned int  newSize  )  [inline]

Definition at line 288 of file IgCollection.h.

References DOUBLE_COLUMN, INT_COLUMN, m_type, STRING_COLUMN, VECTOR_2D, VECTOR_3D, and VECTOR_4D.

00289   {
00290     switch (m_type)
00291     {
00292       case INT_COLUMN:
00293         return doResize<int>(newSize);
00294         break;
00295       case DOUBLE_COLUMN:
00296         return doResize<double>(newSize);
00297         break;
00298       case STRING_COLUMN:
00299         return doResize<std::string>(newSize);
00300         break;
00301       case VECTOR_2D:
00302         return doResize<IgV2d>(newSize);
00303         break;                
00304       case VECTOR_3D:         
00305         return doResize<IgV3d>(newSize);
00306         break;                
00307       case VECTOR_4D:         
00308         return doResize<IgV4d>(newSize);
00309         break;
00310       default:
00311         assert(false);
00312         break;
00313     }
00314   }

int IgColumnHandle::size ( void   )  [inline]

Definition at line 170 of file IgCollection.h.

References DOUBLE_COLUMN, INT_COLUMN, m_data, STRING_COLUMN, type(), VECTOR_2D, VECTOR_3D, and VECTOR_4D.

00171   {
00172     switch (type())
00173     {
00174     case INT_COLUMN:
00175       return static_cast<std::vector<int> *>(m_data)->size();
00176       break;
00177     case STRING_COLUMN:
00178       return static_cast<std::vector<std::string> *>(m_data)->size();
00179       break;
00180     case DOUBLE_COLUMN:
00181       return static_cast<std::vector<double> *>(m_data)->size();
00182       break;
00183     case VECTOR_2D:
00184       return static_cast<std::vector<IgV2d> *>(m_data)->size();
00185       break;
00186     case VECTOR_3D:
00187       return static_cast<std::vector<IgV3d> *>(m_data)->size();
00188       break;
00189     case VECTOR_4D:
00190       return static_cast<std::vector<IgV4d> *>(m_data)->size();
00191       break;
00192     default:
00193       assert (false);
00194     }        
00195   }

void IgColumnHandle::stream ( std::ostream &  stream,
int  position 
) [inline]

Definition at line 197 of file IgCollection.h.

References DOUBLE_COLUMN, INT_COLUMN, STRING_COLUMN, type(), v, VECTOR_2D, VECTOR_3D, and VECTOR_4D.

Referenced by IgCollectionItem::stream().

00198   {
00199     switch (type())
00200     {
00201       case INT_COLUMN:
00202         stream << get<int>(position);
00203         break;
00204       case STRING_COLUMN:
00205         stream << "\""<< get<std::string>(position) << "\"";
00206         break;
00207       case DOUBLE_COLUMN:
00208         stream << get<double>(position);
00209         break;
00210       case VECTOR_2D:
00211         {
00212           IgV2d &v = get<IgV2d>(position);
00213           stream << "("<< v.x() << ", " << v.y() << ")";
00214         }
00215         break;
00216       case VECTOR_3D:
00217         {
00218           IgV3d &v = get<IgV3d>(position);
00219           stream << "("<< v.x() << ", " << v.y() << ", " << v.z() << ")";
00220         }
00221         break;
00222       case VECTOR_4D:
00223         {
00224           IgV4d &v = get<IgV4d>(position);
00225           stream << "("<< v.x() << ", " << v.y() << ", " << v.z() << ", " << v.w() << ")";
00226         }
00227         break;
00228       default:
00229         assert (false);
00230     }
00231   }

void IgColumnHandle::streamType ( std::ostream &  stream  )  [inline]

Definition at line 233 of file IgCollection.h.

References DOUBLE_COLUMN, INT_COLUMN, STRING_COLUMN, type(), VECTOR_2D, VECTOR_3D, and VECTOR_4D.

00234   {
00235     switch (type())
00236     {
00237       case INT_COLUMN:
00238         stream << "int";
00239         break;
00240       case STRING_COLUMN:
00241         stream << "string";
00242         break;
00243       case DOUBLE_COLUMN:
00244         stream << "double";
00245         break;
00246       case VECTOR_2D:
00247         stream << "v2d";
00248         break;
00249       case VECTOR_3D:
00250         stream << "v3d";
00251         break;
00252       case VECTOR_4D:
00253         stream << "v4d";
00254         break;
00255       default:
00256         assert (false);
00257     }
00258   }

ColumnType IgColumnHandle::type ( void   )  [inline]

Definition at line 157 of file IgCollection.h.

References m_type.

Referenced by size(), stream(), and streamType().

00158   { return m_type; }


Member Data Documentation

void* IgColumnHandle::m_data [private]

Definition at line 474 of file IgCollection.h.

Referenced by data(), doClear(), doCompress(), doDestroy(), doExtend(), doReserve(), doResize(), get(), and size().

ColumnType IgColumnHandle::m_type [private]

Definition at line 475 of file IgCollection.h.

Referenced by clear(), compress(), destroy(), extend(), reserve(), resize(), and type().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:25:08 2009 for CMSSW by  doxygen 1.5.4