ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
ALFA_ConfigParams Class Reference

#include <ALFA_ConfigParams.h>

Collaboration diagram for ALFA_ConfigParams:

Public Member Functions

 ALFA_ConfigParams ()
 
virtual ~ALFA_ConfigParams ()
 
bool IsKey (const char *szKey) const
 
const char * GetParameter (const char *szKey) const
 
const char * GetSectionName () const
 
int GetParamsCnt () const
 
int Init (const char *szFile, const char *szSection)
 
void UnInitialize ()
 
void GetMap (MAPSTR2STR &mapParams) const
 

Private Attributes

bool m_bIsValid
 
std::string m_strSection
 
MAPSTR2STR m_mapParams
 

Detailed Description

Definition at line 20 of file ALFA_ConfigParams.h.

Constructor & Destructor Documentation

◆ ALFA_ConfigParams()

ALFA_ConfigParams::ALFA_ConfigParams ( )

Definition at line 18 of file ALFA_ConfigParams.cxx.

19  : m_bIsValid (false),
20  m_strSection ("invalid")
21 {
22 }

◆ ~ALFA_ConfigParams()

ALFA_ConfigParams::~ALFA_ConfigParams ( )
virtual

Definition at line 24 of file ALFA_ConfigParams.cxx.

25 {
26 }

Member Function Documentation

◆ GetMap()

void ALFA_ConfigParams::GetMap ( MAPSTR2STR mapParams) const
inline

Definition at line 38 of file ALFA_ConfigParams.h.

38 { mapParams=m_mapParams; }

◆ GetParameter()

const char * ALFA_ConfigParams::GetParameter ( const char *  szKey) const

Definition at line 82 of file ALFA_ConfigParams.cxx.

83 {
84  if(!m_bIsValid) return nullptr;
85 
86  char szbuff[256];
87  memset(szbuff,0,sizeof(szbuff));
88  if(szKey) strncpy(szbuff,szKey,sizeof(szbuff)-1);
89  //strlwr(szbuff);
90 
91  MAPSTR2STR::const_iterator iter;
92  if((iter=m_mapParams.find(szbuff))!=m_mapParams.end()){
93  return (*iter).second.c_str();
94  }
95  else return nullptr;
96 }

◆ GetParamsCnt()

int ALFA_ConfigParams::GetParamsCnt ( ) const
inline

Definition at line 35 of file ALFA_ConfigParams.h.

35 { return m_mapParams.size(); }

◆ GetSectionName()

const char* ALFA_ConfigParams::GetSectionName ( ) const
inline

Definition at line 34 of file ALFA_ConfigParams.h.

34 { return m_strSection.c_str(); }

◆ Init()

int ALFA_ConfigParams::Init ( const char *  szFile,
const char *  szSection 
)

Definition at line 36 of file ALFA_ConfigParams.cxx.

37 {
38  bool bRes=false;
39  FILE* pfile=nullptr;
40  char szbuff[256],szsec[256];
41  char* ppv;
42 
43  UnInitialize();
44 
45  if((pfile=fopen(szFile,"r"))==nullptr) return false;
46 
47  //read section
48  memset(szsec,0,sizeof(szsec));
49  if(szSection) strncpy(szsec,szSection,sizeof(szsec)-1);
50  //strlwr(szsec);
51  m_strSection=szsec;
52 
53  while(!feof(pfile)){
54  fgets(szbuff,sizeof(szbuff),pfile);
55  if(*(szbuff+strlen(szbuff)-1)=='\n') *(szbuff+strlen(szbuff)-1)=0;
56  if(strcmp(szbuff,szsec) != 0) continue; //if(strcmp(strlwr(szbuff),szsec)) continue;
57  else{ bRes=true; break; }
58  }
59 
60  if(!bRes){
61  fclose(pfile);
62  return 0;
63  }
64 
65  while(!feof(pfile)){
66  fgets(szbuff,sizeof(szbuff),pfile);
67  if(*szbuff==0 || *szbuff==' ' || *szbuff=='\n' || *szbuff==';') continue;
68  if(*szbuff=='[') break;
69  if((ppv=strchr(szbuff,'='))==nullptr) continue;
70 
71  if(*(szbuff+strlen(szbuff)-1)=='\n') *(szbuff+strlen(szbuff)-1)=0;
72  *ppv=0; ppv++;
73  m_mapParams.insert(MAPSTR2STR::value_type(szbuff,ppv)); //m_mapParams.insert(MAPSTR2STR::value_type(strlwr(szbuff),ppv));
74  }
75 
76  fclose(pfile);
77  if(!m_mapParams.empty()) m_bIsValid=true;
78 
79  return m_mapParams.size();
80 }

◆ IsKey()

bool ALFA_ConfigParams::IsKey ( const char *  szKey) const

Definition at line 98 of file ALFA_ConfigParams.cxx.

99 {
100  if(!m_bIsValid) return false;
101 
102  char szbuff[256];
103  memset(szbuff,0,sizeof(szbuff));
104  if(szKey) strncpy(szbuff,szKey,sizeof(szbuff)-1);
105  //strlwr(szbuff);
106 
107  MAPSTR2STR::const_iterator iter;
108  return (iter=m_mapParams.find(szbuff))!=m_mapParams.end();
109 }

◆ UnInitialize()

void ALFA_ConfigParams::UnInitialize ( )

Definition at line 28 of file ALFA_ConfigParams.cxx.

29 {
30  m_bIsValid=false;
31 
32  m_strSection="invalid";
33  m_mapParams.clear();
34 }

Member Data Documentation

◆ m_bIsValid

bool ALFA_ConfigParams::m_bIsValid
private

Definition at line 27 of file ALFA_ConfigParams.h.

◆ m_mapParams

MAPSTR2STR ALFA_ConfigParams::m_mapParams
private

Definition at line 29 of file ALFA_ConfigParams.h.

◆ m_strSection

std::string ALFA_ConfigParams::m_strSection
private

Definition at line 28 of file ALFA_ConfigParams.h.


The documentation for this class was generated from the following files:
LArNewCalib_Delay_OFC_Cali.pfile
string pfile
Definition: LArNewCalib_Delay_OFC_Cali.py:173
ALFA_ConfigParams::m_mapParams
MAPSTR2STR m_mapParams
Definition: ALFA_ConfigParams.h:29
ALFA_ConfigParams::UnInitialize
void UnInitialize()
Definition: ALFA_ConfigParams.cxx:28
ALFA_ConfigParams::m_bIsValid
bool m_bIsValid
Definition: ALFA_ConfigParams.h:27
ALFA_ConfigParams::m_strSection
std::string m_strSection
Definition: ALFA_ConfigParams.h:28