Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

PartialTuple.h

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/reconstruction/reconstruction/PartialTuple.h,v 1.1.1.1 1999/12/28 01:36:02 burnett Exp $
00002 // header file for PartialTuple class.
00003 // written by T.H. Burnett
00004 // moved to PartialTuple.h 6.25.98 by HSG
00005 
00006 #ifndef PARTIALTUPLE_H_
00007 #define PARTIALTUPLE_H_
00008 
00009 #include "reconstruction/GlastTuple.h"
00010 #include <set>
00011 #include <iomanip>
00012 
00013 // note: does not dereference the namespace - should compile on gcc
00014 
00015 
00016 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00017 class PartialTuple : public GlastTuple {
00018 public:
00019     PartialTuple(const std::string& item_list)
00020     {
00021 
00022         if( item_list.empty() ) return;
00023         size_type i=0;
00024         
00025         // tokenize the list here
00026         while( 1 ){
00027             std::string::size_type j 
00028                   = item_list.substr(i).find_first_not_of("\n\t ");
00029             if( j==std::string::npos) break;
00030             i += j;
00031             std::string::size_type len 
00032                   = item_list.substr(i).find_first_of("\n\t ");
00033 
00034             std::string n = item_list.substr(i,len);
00035             if(!n.empty() )  m_item_names.insert(n);
00036             if (len == std::string::npos ) break;
00037             i += len;
00038         }
00039     }
00040    void addItem (const char* name, const float* datum)
00041    {
00042         if( m_item_names.empty() 
00043             ||  m_item_names.find(std::string(name)) != m_item_names.end() ) 
00044             GlastTuple::addItem(name, datum);
00045    }
00046    void printOn(std::ostream& out)const
00047    {
00048         out  << "======================================\n"
00049              << (m_item_names.empty()? 
00050                     "     Standard Tuple\n"
00051                    :"       User Tuple\n")
00052              << "======================================\n" ;
00053 
00054         for(const_iterator it = begin(); it != end(); ++it) {
00055             float d = **it;
00056              out << std::setw(24) 
00057                 << (*it)->name().c_str() << '\t'
00058                 << d << '\n'; 
00059         }
00060    }
00061 private:
00062    std::set<std::string> m_item_names;
00063 };
00064 
00065 #endif

Generated at Wed Nov 21 12:20:44 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000