Changeset 8724 for trunk/MagicSoft/Mars/mbase/MParContainer.cc
- Timestamp:
- 08/31/07 14:11:36 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r8642 r8724 868 868 } 869 869 870 // -------------------------------------------------------------------------- 871 // 872 // Check if the given resource is defined. If there is a postfix, prefix 873 // the postfix with a dot. Calls IsEnvDefined(env, name, print) 874 // 870 875 Bool_t MParContainer::IsEnvDefined(const TEnv &env, TString prefix, TString postfix, Bool_t print) const 871 876 { … … 876 881 } 877 882 883 // -------------------------------------------------------------------------- 884 // 885 // If print==kTRUE print information about what's going on. This is necessary 886 // to debug parsing of resource files. Check if a resource "name" is defined 887 // and return kFALSE/kTRUE depending on the result. 888 // 878 889 Bool_t MParContainer::IsEnvDefined(const TEnv &env, TString name, Bool_t print) const 879 890 { … … 881 892 *fLog << all << GetDescriptor() << " - " << name << "... " << flush; 882 893 883 if (! ((TEnv&)env).Defined(name))894 if (!const_cast<TEnv&>(env).Defined(name)) 884 895 { 885 896 if (print) … … 894 905 } 895 906 907 // -------------------------------------------------------------------------- 908 // 909 // Return the resource prefix+"."+postfix from env or deftl if not available. 910 // If prefix IsNull search for postfix only. 911 // 896 912 Int_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, TString postfix, Int_t dflt) const 897 913 { 898 return GetEnvValue(env, prefix+"."+postfix, dflt); 899 } 900 914 return GetEnvValue(env, prefix.IsNull()?postfix:(prefix+"."+postfix), dflt); 915 } 916 917 // -------------------------------------------------------------------------- 918 // 919 // Return the resource prefix+"."+postfix from env or deftl if not available. 920 // If prefix IsNull search for postfix only. 921 // 901 922 Double_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, TString postfix, Double_t dflt) const 902 923 { 903 return GetEnvValue(env, prefix+"."+postfix, dflt); 904 } 905 924 return GetEnvValue(env, prefix.IsNull()?postfix:(prefix+"."+postfix), dflt); 925 } 926 927 // -------------------------------------------------------------------------- 928 // 929 // Return the resource prefix+"."+postfix from env or deftl if not available. 930 // If prefix IsNull search for postfix only. 931 // 906 932 const char *MParContainer::GetEnvValue(const TEnv &env, TString prefix, TString postfix, const char *dflt) const 907 933 { 908 return GetEnvValue(env, prefix+"."+postfix, dflt); 909 } 910 934 return GetEnvValue(env, prefix.IsNull()?postfix:(prefix+"."+postfix), dflt); 935 } 936 937 // -------------------------------------------------------------------------- 938 // 939 // Return the resource prefix from env or deftl if not available. 940 // 911 941 Int_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, Int_t dflt) const 912 942 { 913 return ((TEnv&)env).GetValue(prefix, dflt); 914 } 915 943 return const_cast<TEnv&>(env).GetValue(prefix, dflt); 944 } 945 946 // -------------------------------------------------------------------------- 947 // 948 // Return the resource prefix from env or deftl if not available. 949 // 916 950 Double_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, Double_t dflt) const 917 951 { 918 return ((TEnv&)env).GetValue(prefix, dflt); 919 } 920 952 return const_cast<TEnv&>(env).GetValue(prefix, dflt); 953 } 954 955 // -------------------------------------------------------------------------- 956 // 957 // Return the resource prefix from env or deftl if not available. 958 // 921 959 const char *MParContainer::GetEnvValue(const TEnv &env, TString prefix, const char *dflt) const 922 960 { 923 return ((TEnv&)env).GetValue(prefix, dflt); 961 return const_cast<TEnv&>(env).GetValue(prefix, dflt); 962 } 963 964 // -------------------------------------------------------------------------- 965 // 966 // Check for the resource prefix+"."+postfix. If it is not available or 967 // prefix IsNull check for the more common resource postfix. If none 968 // is found return the default. 969 // 970 template <class T> 971 T MParContainer::GetEnvValue2Imp(const TEnv &env, const TString &prefix, const TString &postfix, T dftl, Bool_t print) const 972 { 973 // Check for a dedicated resource (prefix.postfix) first 974 if (!prefix.IsNull()) 975 { 976 if (IsEnvDefined(env, prefix, postfix, print)) 977 return GetEnvValue(env, prefix, postfix, dftl); 978 } 979 980 // check for a general resource (postfix) 981 if (IsEnvDefined(env, postfix, print)) 982 return GetEnvValue(env, postfix, dftl); 983 984 // return default 985 return dftl; 986 } 987 988 // -------------------------------------------------------------------------- 989 // 990 // see template GetEnvValue2Imp 991 // 992 const char *MParContainer::GetEnvValue2(const TEnv &env, const TString &prefix, const TString &postfix, const char *dftl, Bool_t print) const 993 { 994 return GetEnvValue2Imp(env, prefix, postfix, dftl, print); 995 } 996 997 // -------------------------------------------------------------------------- 998 // 999 // see template GetEnvValue2Imp 1000 // 1001 Int_t MParContainer::GetEnvValue2(const TEnv &env, const TString &prefix, const TString &postfix, Int_t dftl, Bool_t print) const 1002 { 1003 return GetEnvValue2Imp(env, prefix, postfix, dftl, print); 1004 } 1005 1006 // -------------------------------------------------------------------------- 1007 // 1008 // see template GetEnvValue2Imp 1009 // 1010 Double_t MParContainer::GetEnvValue2(const TEnv &env, const TString &prefix, const TString &postfix, Double_t dftl, Bool_t print) const 1011 { 1012 return GetEnvValue2Imp(env, prefix, postfix, dftl, print); 924 1013 } 925 1014
Note:
See TracChangeset
for help on using the changeset viewer.