33G4HadronicDeveloperParameters::G4HadronicDeveloperParameters(){
41 const std::map< std::string , const G4bool >::iterator it = b_defaults.find( name );
42 if ( it == b_defaults.end() ) {
44 b_defaults.insert( std::pair<std::string, const G4bool>( name , value ) );
45 b_values.insert( std::pair<std::string, G4bool>( name , value ) );
48 issue_is_already_defined( name );
55 const std::map< std::string , const G4int >::iterator it = i_defaults.find( name );
56 if ( it == i_defaults.end() ) {
58 i_defaults.insert( std::pair<std::string, const G4int>( name , value ) );
59 i_values.insert( std::pair<std::string, G4int>( name , value ) );
60 i_limits.insert( std::pair< std::string,std::pair< const G4int , const G4int> >( name, std::pair< const G4int , const G4int> ( lower_limit , upper_limit ) ) );
63 issue_is_already_defined( name );
70 const std::map< std::string , const G4double >::iterator it = defaults.find( name );
71 if ( it == defaults.end() ) {
73 defaults.insert( std::pair<std::string, const G4double>( name , value ) );
74 values.insert( std::pair<std::string, G4double>( name , value ) );
75 limits.insert( std::pair< std::string,std::pair< const G4double , const G4double> >( name, std::pair< const G4double , const G4double> ( lower_limit , upper_limit ) ) );
78 issue_is_already_defined( name );
85 const std::map<std::string,G4bool>::iterator it = b_values.find( name );
86 if ( it != b_values.end() ) {
87 if ( it->second == b_defaults.find(name)->second ) {
92 issue_has_changed( name );
96 issue_no_param( name );
103 const std::map<std::string,G4int>::iterator it = i_values.find( name );
104 if ( it != i_values.end() ) {
105 if ( it->second == i_defaults.find(name)->second ) {
106 if ( check_value_within_limits( i_limits.find(name)->second , value ) ) {
112 issue_non_eligible_value( name );
116 issue_has_changed( name );
120 issue_no_param( name );
127 const std::map<std::string,G4double>::iterator it = values.find( name );
128 if ( it != values.end() ) {
129 if ( it->second == defaults.find(name)->second ) {
130 if ( check_value_within_limits( limits.find(name)->second , value ) ) {
136 issue_non_eligible_value( name );
140 issue_has_changed( name );
144 issue_no_param( name );
151 const std::map<std::string,const G4bool>::iterator it = b_defaults.find( name );
152 if ( it != b_defaults.end() ) {
157 issue_no_param( name );
164 const std::map<std::string,const G4int>::iterator it = i_defaults.find( name );
165 if ( it != i_defaults.end() ) {
170 issue_no_param( name );
177 const std::map<std::string,const G4double>::iterator it = defaults.find( name );
178 if ( it != defaults.end() ) {
183 issue_no_param( name );
189 return get( name , value );
193 return get( name , value ,
true );
196G4bool G4HadronicDeveloperParameters::get(
const std::string name ,
G4bool& value ,
G4bool check_change ) {
198 const std::map<std::string,G4bool>::iterator it = b_values.find( name );
199 if ( it != b_values.end() ) {
202 if ( check_change && value != b_defaults.find(name)->second ) {
204 issue_is_modified( name );
208 issue_no_param( name );
214 return get( name , value );
218 return get( name , value ,
true );
221G4bool G4HadronicDeveloperParameters::get(
const std::string name ,
G4int& value ,
G4bool check_change ) {
223 const std::map<std::string,G4int>::iterator it = i_values.find( name );
224 if ( it != i_values.end() ) {
227 if ( check_change && value != i_defaults.find(name)->second ) {
229 issue_is_modified( name );
233 issue_no_param( name );
239 return get( name , value );
243 return get( name , value ,
true );
246G4bool G4HadronicDeveloperParameters::get(
const std::string name ,
G4double& value ,
G4bool check_change ) {
248 const std::map<std::string,G4double>::iterator it = values.find( name );
249 if ( it != values.end() ) {
252 if ( check_change && value != defaults.find(name)->second ) {
254 issue_is_modified( name );
258 issue_no_param( name );
265 if ( b_values.find( name ) != b_values.end() ) {
266 G4cout <<
"G4HadronicDeveloperParameters: "
268 <<
", default value = " << b_defaults.find( name )->second
269 <<
", current value = " << b_values.find( name )->second
271 }
else if ( i_values.find( name ) != i_values.end() ) {
272 G4cout <<
"G4HadronicDeveloperParameters: "
274 <<
", default value = " << i_defaults.find( name )->second
275 <<
", lower limit = " << i_limits.find( name )->second.first
276 <<
", upper limit = " << i_limits.find( name )->second.second
277 <<
", current value = " << i_values.find( name )->second
279 }
else if ( values.find( name ) != values.end() ) {
280 G4cout <<
"G4HadronicDeveloperParameters: "
282 <<
", default value = " << defaults.find( name )->second
283 <<
", lower limit = " << limits.find( name )->second.first
284 <<
", upper limit = " << limits.find( name )->second.second
285 <<
", current value = " << values.find( name )->second
289 issue_no_param( name );
293G4bool G4HadronicDeveloperParameters::check_value_within_limits( std::pair<const G4double,const G4double>& alimits ,
const G4double value ){
294 if ( alimits.first <= value && value <= alimits.second ) {
301G4bool G4HadronicDeveloperParameters::check_value_within_limits( std::pair<const G4int,const G4int>& alimits ,
const G4int value ){
302 if ( alimits.first <= value && value <= alimits.second ) {
309void G4HadronicDeveloperParameters::issue_no_param(
const std::string& name ){
310 std::string text(
"Parameter ");
312 text +=
" does not exist.";
316void G4HadronicDeveloperParameters::issue_has_changed(
const std::string& name ) {
317 std::string text(
"Parameter ");
319 text +=
" has already been changed once.";
322void G4HadronicDeveloperParameters::issue_non_eligible_value(
const std::string& name ) {
323 std::string text(
"The value of the parameter ");
325 text +=
" is outside the allowable range.";
328void G4HadronicDeveloperParameters::issue_is_already_defined(
const std::string& name ) {
329 std::string text(
"Parameter ");
331 text +=
" is already defined.";
334void G4HadronicDeveloperParameters::issue_is_modified(
const std::string& name ) {
335 std::string text(
"Parameter ");
337 text +=
" has changed from default value.";
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
G4bool DeveloperGet(const std::string name, G4bool &value)
void Dump(const std::string name)
G4bool Get(const std::string name, G4bool &value)
G4bool Set(const std::string name, const G4bool)
static G4HadronicDeveloperParameters & GetInstance()
G4bool SetDefault(const std::string name, const G4bool value)
G4bool GetDefault(const std::string name, G4bool &value)
const char * name(G4int ptype)