inlib  1.2.0
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
inlib::waxml::ntuple Class Reference

List of all members.

Classes

class  column
class  iobj
class  leaf
class  sub_ntuple

Public Member Functions

 ntuple (std::ostream &a_writer, unsigned int a_spaces=0)
virtual ~ntuple ()
const std::vector< iobj * > & columns () const
template<class T >
column< T > * create_column (const std::string &a_name, const T &a_def=T())
sub_ntuplecreate_sub_ntuple (const std::string &a_name)
void write_header (const std::string &a_path, const std::string &a_name, const std::string &a_title)
bool add_row ()
void write_trailer ()

Protected Member Functions

 ntuple (const ntuple &a_from)
ntupleoperator= (const ntuple &a_from)

Static Protected Member Functions

static cid _cid (int)
static cid _cid (float)
static cid _cid (double)
static const std::string & s_aida_type (int)
static const std::string & s_aida_type (float)
static const std::string & s_aida_type (double)
static void get_booking (const std::vector< iobj * > &a_cols, std::string &a_string)

Protected Attributes

std::ostream & m_writer
std::string m_path
std::string m_name
std::string m_title
std::string m_spaces
std::vector< iobj * > m_cols

Detailed Description

Definition at line 24 of file ntuple.


Constructor & Destructor Documentation

inlib::waxml::ntuple::ntuple ( std::ostream &  a_writer,
unsigned int  a_spaces = 0 
) [inline]

Definition at line 194 of file ntuple.

  :m_writer(a_writer){
    for(unsigned int i=0;i<a_spaces;i++) m_spaces += " ";
  }
virtual inlib::waxml::ntuple::~ntuple ( ) [inline, virtual]

Definition at line 199 of file ntuple.

                    {
    inlib::clear<iobj>(m_cols);
  }
inlib::waxml::ntuple::ntuple ( const ntuple a_from) [inline, protected]

Definition at line 203 of file ntuple.

  :m_writer(a_from.m_writer)
  ,m_spaces(a_from.m_spaces)
  {}

Member Function Documentation

static cid inlib::waxml::ntuple::_cid ( int  ) [inline, static, protected]

Definition at line 26 of file ntuple.

{return 1;}
static cid inlib::waxml::ntuple::_cid ( float  ) [inline, static, protected]

Definition at line 27 of file ntuple.

{return 2;}
static cid inlib::waxml::ntuple::_cid ( double  ) [inline, static, protected]

Definition at line 28 of file ntuple.

{return 3;}
bool inlib::waxml::ntuple::add_row ( ) [inline]

Definition at line 271 of file ntuple.

                 {
    if(m_cols.empty()) return false;
    m_writer << m_spaces << "      <row>" << std::endl;
    std::vector<iobj*>::const_iterator it;
    for(it=m_cols.begin();it!=m_cols.end();++it) {
      if(sub_ntuple* sub = id_cast<iobj,sub_ntuple>(*(*it))){
        m_writer << m_spaces << "        <entryITuple>" << std::endl;
        m_writer << sub->value();
        m_writer << m_spaces << "        </entryITuple>" << std::endl;
        sub->reset();
      } else if(leaf* lf = id_cast<iobj,leaf>(*(*it))){
        m_writer << m_spaces << "        <entry" 
                 << " value=" << sout(lf->s_value())
                 << "/>" << std::endl;
      }
    }
    m_writer << m_spaces << "      </row>" << std::endl;
    return true;
  }
const std::vector<iobj*>& inlib::waxml::ntuple::columns ( ) const [inline]

Definition at line 212 of file ntuple.

{return m_cols;}
template<class T >
column<T>* inlib::waxml::ntuple::create_column ( const std::string &  a_name,
const T &  a_def = T() 
) [inline]

Definition at line 215 of file ntuple.

                                                        {
    if(find_named<iobj>(m_cols,a_name)) return 0;
    column<T>* col = new column<T>(a_name,a_def);
    if(!col) return 0;
    m_cols.push_back(col);
    return col;
  }
sub_ntuple* inlib::waxml::ntuple::create_sub_ntuple ( const std::string &  a_name) [inline]

Definition at line 224 of file ntuple.

                                                        {
    if(find_named<iobj>(m_cols,a_name)) return 0;
    std::string spaces;
    for(unsigned int i=0;i<10;i++) spaces += " ";
    sub_ntuple* col = new sub_ntuple(a_name,m_spaces+spaces);
    if(!col) return 0;
    m_cols.push_back(col);
    return col;
  }
static void inlib::waxml::ntuple::get_booking ( const std::vector< iobj * > &  a_cols,
std::string &  a_string 
) [inline, static, protected]

Definition at line 297 of file ntuple.

                                                      {
    a_string += "{"; //we need the + because of the tuple in tuple.

    std::vector<iobj*>::const_iterator it;
    for(it=a_cols.begin();it!=a_cols.end();++it) {
      if(it!=a_cols.begin()) a_string += ",";

      std::string type = (*it)->aida_type();
      a_string += type + " ";
      std::string name = (*it)->name();
      a_string += name + " = ";

      if(sub_ntuple* sub = id_cast<iobj,sub_ntuple>(*(*it))){
        get_booking(sub->columns(),a_string);
      } else if(leaf* lf = id_cast<iobj,leaf>(*(*it))){
        a_string += lf->s_def();
      }  
    }  
    a_string += "}";
  }
ntuple& inlib::waxml::ntuple::operator= ( const ntuple a_from) [inline, protected]

Definition at line 207 of file ntuple.

                                         {
    m_spaces = a_from.m_spaces;
    return *this;
  }
static const std::string& inlib::waxml::ntuple::s_aida_type ( int  ) [inline, static, protected]

Definition at line 57 of file ntuple.

                                           {
    static const std::string s_v("int");
    return s_v;
  }
static const std::string& inlib::waxml::ntuple::s_aida_type ( float  ) [inline, static, protected]

Definition at line 61 of file ntuple.

                                             {
    static const std::string s_v("float");
    return s_v;
  }
static const std::string& inlib::waxml::ntuple::s_aida_type ( double  ) [inline, static, protected]

Definition at line 65 of file ntuple.

                                              {
    static const std::string s_v("double");
    return s_v;
  }
void inlib::waxml::ntuple::write_header ( const std::string &  a_path,
const std::string &  a_name,
const std::string &  a_title 
) [inline]

Definition at line 234 of file ntuple.

                                                    {

    // <tuple> :
    m_writer << m_spaces << "  <tuple"
             << " path=" << sout(a_path)
             << " name=" << sout(a_name)
             << " title=" << sout(a_title)
             << ">" << std::endl;

    // <columns> :
    m_writer << m_spaces << "    <columns>" << std::endl;

    std::vector<iobj*>::iterator it;
    for(it=m_cols.begin();it!=m_cols.end();++it) {
      if(sub_ntuple* sub = id_cast<iobj,sub_ntuple>(*(*it))){
        m_writer << m_spaces << "      <column"
                 << " name=" << sout((*it)->name()) 
                 << " type=" << sout("ITuple")
                 << " booking=" << sout(sub->booking())
                 << "/>" << std::endl;
      } else if(leaf* lf = id_cast<iobj,leaf>(*(*it))){
        m_writer << m_spaces << "      <column"
                 << " name=" << sout((*it)->name()) 
                 << " type=" << sout((*it)->aida_type())
                 << " default=" << sout(lf->s_def())
                 << "/>" << std::endl;
      }
    }

    m_writer << m_spaces << "    </columns>" << std::endl;
  
    // rows :
    m_writer << m_spaces << "    <rows>" << std::endl;
  }
void inlib::waxml::ntuple::write_trailer ( ) [inline]

Definition at line 291 of file ntuple.

                       {
    m_writer << m_spaces << "    </rows>" << std::endl;
    m_writer << m_spaces << "  </tuple>" << std::endl;
  }

Member Data Documentation

std::vector<iobj*> inlib::waxml::ntuple::m_cols [protected]

Definition at line 325 of file ntuple.

std::string inlib::waxml::ntuple::m_name [protected]

Definition at line 322 of file ntuple.

std::string inlib::waxml::ntuple::m_path [protected]

Definition at line 321 of file ntuple.

std::string inlib::waxml::ntuple::m_spaces [protected]

Definition at line 324 of file ntuple.

std::string inlib::waxml::ntuple::m_title [protected]

Definition at line 323 of file ntuple.

std::ostream& inlib::waxml::ntuple::m_writer [protected]

Definition at line 320 of file ntuple.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines