Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4UIaliasList.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4UIaliasList.cc 67965 2013-03-13 09:35:29Z gcosmo $
28 //
29 
30 #include "G4UIaliasList.hh"
31 #include "G4ios.hh"
32 
34 { }
35 
37 {
38  G4int i;
39  G4int n_treeEntry = alias.size();
40  for( i=0; i < n_treeEntry; i++ )
41  { delete alias[i];
42  delete value[i]; }
43 }
44 
46 {
47  return ( this == &right );
48 }
49 
51 {
52  return ( this != &right );
53 }
54 
55 void G4UIaliasList::AddNewAlias(const char* aliasName, const char* aliasValue)
56 {
57  if(FindAlias(aliasName))
58  {
59  G4cerr << "Alias <" << aliasName << "> already exist. Command ignored."
60  << G4endl;
61  return;
62  }
63  G4String* newAlias = new G4String(aliasName);
64  alias.push_back(newAlias);
65  G4String* newValue = new G4String(aliasValue);
66  value.push_back(newValue);
67 }
68 
69 void G4UIaliasList::RemoveAlias(const char* aliasName)
70 {
71  G4int i = FindAliasID(aliasName);
72  if(i<0)
73  {
74  G4cerr << "Alias <" << aliasName << "> does not exist. Command ignored."
75  << G4endl;
76  return;
77  }
78  alias.erase(alias.begin()+i);
79  value.erase(value.begin()+i);
80 }
81 
82 void G4UIaliasList::ChangeAlias(const char* aliasName, const char* aliasValue)
83 {
84  G4int i = FindAliasID(aliasName);
85  if(i<0)
86  {
87  AddNewAlias(aliasName,aliasValue);
88  return;
89  }
90  *(value[i]) = aliasValue;
91 }
92 
93 G4String* G4UIaliasList::FindAlias(const char* aliasName)
94 {
95  G4int i = FindAliasID(aliasName);
96  if(i<0)
97  { return 0; }
98  return value[i];
99 }
100 
101 G4int G4UIaliasList::FindAliasID(const char* aliasName)
102 {
103  G4int i_entry = alias.size();
104  for(G4int i=0;i<i_entry;i++)
105  { if(*(alias[i])==aliasName) return i; }
106  return -1;
107 }
108 
110 {
111  G4int i_entry = alias.size();
112  for(G4int i1=0;i1<i_entry-1;i1++)
113  for(G4int i2=i1+1;i2<i_entry;i2++)
114  {
115  if(*(alias[i1])>*(alias[i2]))
116  {
117  G4String* tmp = alias[i1];
118  alias[i1] = alias[i2];
119  alias[i2] = tmp;
120  tmp = value[i1];
121  value[i1] = value[i2];
122  value[i2] = tmp;
123  }
124  }
125 
126  for(G4int i=0;i<i_entry;i++)
127  { G4cout << " " << *(alias[i]) << " : " << *(value[i]) << G4endl; }
128 }
129 
#define G4endl
Definition: G4ios.hh:61
G4int operator!=(const G4UIaliasList &right) const
void AddNewAlias(const char *aliasName, const char *aliasValue)
Float_t tmp
const XML_Char int const XML_Char * value
Definition: expat.h:331
void RemoveAlias(const char *aliasName)
G4GLOB_DLL std::ostream G4cerr
void ChangeAlias(const char *aliasName, const char *aliasValue)
G4int FindAliasID(const char *aliasName)
int G4int
Definition: G4Types.hh:78
G4int operator==(const G4UIaliasList &right) const
G4GLOB_DLL std::ostream G4cout
std::vector< G4String * > alias
G4String * FindAlias(const char *aliasName)