00001
00002
00003
00004
00005
00006 #ifndef PARTIALTUPLE_H_
00007 #define PARTIALTUPLE_H_
00008
00009 #include "reconstruction/GlastTuple.h"
00010 #include <set>
00011 #include <iomanip>
00012
00013
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
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