GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InfoData.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004 by Olivier Stezowski *
3  * stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #ifndef ROOT_TString
24 #include <TString.h>
25 #endif
26 
27 #ifndef GW_INFODATA_H
28 #include "InfoData.h"
29 #endif
30 
31 using namespace Gw;
32 
34 
35 InfoData::InfoData() : TObject(), fInfo(kKnown)
36 {
37 }
38 
39 InfoData::InfoData(const InfoData &info):TObject(info) { fInfo = info.fInfo; }
40 
42 {
43 }
44 
46 {
47  TString st = s; Short_t nb, nb_unkown, nb_theo_left, nb_theo_right, nb_tenta_left, nb_tenta_right, nb_about;
48 
49  // reads the string and counts the specfics characters
50  nb = nb_unkown = nb_theo_left = nb_theo_right = nb_tenta_left = nb_tenta_right = nb_about = 0;
51  Int_t end = st.Length();
52  for( Int_t i = 0 ; i < end; i++ ){
53  if ( st[i] == '?' ) { nb_unkown++; nb++; }
54  if ( st[i] == '(' ) { nb_tenta_left++; nb++;} ; if ( st[i] == ')' ) { nb_tenta_right++; nb++;}
55  if ( st[i] == '[' ) { nb_theo_left++; nb++; } ; if ( st[i] == ']' ) { nb_theo_right++; nb++; }
56  if ( st[i] == '~' ) { nb_about++; nb++; }
57  }
58  // set the informations
59  if ( nb > 2 ) return kUnknown;
60  if ( nb == 0 ) return kKnown;
61 
62  if ( nb == 1 ) {
63  if ( nb_about == 1 ) return kAbout;
64  else return kUnknown;
65  }
66  else { // nb = 2
67  if ( nb_tenta_left == 1 && nb_tenta_right == 1 ) return kTentative;
68  if ( nb_theo_left == 1 && nb_theo_right == 1 ) return kTheo;
69  }
70  return kUnknown;
71 }
72 
73 
static EData WhatIs(const char *)
It deduces from a string the kind of data.
Definition: InfoData.cpp:45
header file for InfoData
virtual ~InfoData()
Definition: InfoData.cpp:41
EData
flags that qualify a given data
Definition: InfoData.h:55
UShort_t fInfo
Definition: InfoData.h:49
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
Base class to get/set some flag informations concerning any data.
Definition: InfoData.h:46
ClassImp(InfoData)