32 #include "KVGitInfo.h"
34 #include "KVVersion.h"
56 #define xstr(s) str(s)
67 if (strcmp(namefile,
""))
return Form(
"%s/%s",
xstr(ETCDIR), namefile);
76 if (strcmp(namefile,
""))
return Form(
"%s/%s",
xstr(DATADIR), namefile);
85 if (strcmp(namefile,
""))
return Form(
"%s/%s",
xstr(TEMPLATEDIR), namefile);
86 return Form(
"%s",
xstr(TEMPLATEDIR));
94 return Form(
"%s/db", fWorkingDirectory.Data());
102 if (strcmp(namefile,
""))
return Form(
"%s/%s",
xstr(LIBDIR), namefile);
111 if (strcmp(namefile,
""))
return Form(
"%s/%s",
xstr(INCDIR), namefile);
120 if (strcmp(namefile,
""))
return Form(
"%s/%s",
xstr(BINDIR), namefile);
129 if (strcmp(namefile,
""))
return Form(
"%s/%s", fWorkingDirectory.Data(), namefile);
130 return fWorkingDirectory;
146 SetBit(kIsKaliVedaObject);
217 TString libdir = GetLIBDIRFilePath();
221 KVString add_dyn_path(ADD_DYN_PATH);
222 add_dyn_path.
Begin(
";");
223 while (!add_dyn_path.
End()) {
231 TString incdir = GetINCDIRFilePath();
239 #ifdef WITH_GNU_INSTALL
241 fWorkingDirectory =
gEnv->
GetValue(
"KaliVeda.WorkingDirectory",
"$(HOME)/.kaliveda");
246 fWorkingDirectory = KV_ROOT;
284 TString tmp = GetETCDIRFilePath(
"config.files");
286 conflist.open(tmp.
Data());
287 if (!conflist.good()) {
288 ::Fatal(
"KVBase::ReadConfigFiles",
"Cannot open %s", tmp.
Data());
292 file.ReadLine(conflist);
295 while (!
file.End()) {
296 tmp = GetETCDIRFilePath(
file.Next().Data());
309 gROOT->GetPluginManager()->LoadHandlersFromEnv(
gEnv);
312 if (!
gROOT->IsBatch()) ReadGUIMimeTypes();
346 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
349 ((
KVBase&) obj).Copy(*
this);
362 if (&other !=
this) {
392 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
405 ((
KVBase&) obj).SetNumber(fNumber);
406 ((
KVBase&) obj).SetLabel(fLabel);
415 cout <<
"KVBase object: Name=" <<
GetName() <<
" Type=" <<
GetType();
431 void KVBase::Streamer(
TBuffer& R__b)
443 TNamed::Streamer(R__b);
451 KVBase::Class()->ReadBuffer(R__b,
this, R__v, R__s, R__c);
456 TNamed::Streamer(R__b);
470 KVBase::Class()->WriteBuffer(R__b,
this);
506 va_start(args, ndirs);
508 for (; ndirs; ndirs--) {
564 if (strcmp(kvsubdir,
"")) {
569 kvfile_dir = kvsubdir;
686 else if (strcmp(kvsubdir,
"")) {
735 TString backup = fullpath +
"." + date;
738 if (lf1.Lock() && lf2.
Lock()) {
740 printf(
"Info in <KVBase::BackupFileWithDate(const Char_t *)> : Existing file %s renamed %s\n",
798 fp.open(base.
Data());
827 base = tmp1 + (++lnow);
840 static TString tmp(KV_VERSION);
853 static TString tmp(KV_BUILD_USER);
866 static TString tmp(KV_BUILD_DATE);
878 static TString tmp(KV_BUILD_TIME);
891 static TString tmp(KV_BUILD_TYPE);
904 static TString tmp(KV_SOURCE_DIR);
917 static TString tmp(KV_BUILD_DIR);
922 #ifdef WITH_GIT_INFOS
930 static TString tmp(KV_GIT_BRANCH);
942 static TString tmp(KV_GIT_COMMIT);
980 TString spath(path), backup(exec), backup2(exec), expandexec(exec);
992 expandexec +=
".exe";
1005 if (!backup.EndsWith(
".exe")) {
1027 #ifdef __WITHOUT_TSYSTEM_FINDFILE
1101 ok_imp = ok_dec =
kFALSE;
1104 for (i = 0; i < impl_alt.
GetNpar(); i++) {
1111 for (i = 0; i < decl_alt.
GetNpar(); i++) {
1118 return (ok_imp && ok_dec);
1161 while ((er = (
TEnvRec*) next())) {
1163 if ((
s = strstr(er->
GetName(),
"Plugin."))) {
1172 if (strcmp(
s, base))
continue;
1177 if (regexp.
IsNull())
break;
1178 TString clss = strtok(0,
"; ");
1179 if (clss.
IsNull())
break;
1180 TString plugin = strtok(0,
"; ");
1181 if (plugin.
IsNull())
break;
1182 TString ctor = strtok(0,
";\"");
1184 ctor = strtok(0,
";\"");
1185 if (clss == derived) {
1241 while ((er = (
TEnvRec*) next())) {
1243 if ((
s = strstr(er->
GetName(),
"Plugin."))) {
1252 if (strcmp(
s, base))
continue;
1257 if (regexp.
IsNull())
break;
1258 TString clss = strtok(0,
"; ");
1259 if (clss.
IsNull())
break;
1260 TString plugin = strtok(0,
"; ");
1261 if (plugin.
IsNull())
break;
1262 TString ctor = strtok(0,
";\"");
1264 ctor = strtok(0,
";\"");
1305 while (!plugs.
End()) {
1306 if (tmp !=
"") tmp +=
" ";
1329 while ((er = (
TEnvRec*) next())) {
1336 while (!erval.
End()) {
1375 if (mimetypes !=
"") {
1377 mimetypes.
Begin(
" ");
1378 while (!mimetypes.
End()) {
1424 if (A == B)
return true;
1437 if (Aint < 0) Aint = zero.i - Aint;
1438 if (Bint < 0) Bint = zero.i - Bint;
1440 Long64_t intDiff = abs(val1.i - val2.i);
1442 if (intDiff <= maxdif)
return true;
1468 TMethod*
m = obj->IsA()->GetMethodAllAny(method);
1470 obj->
Warning(
"OpenContextMenu",
"%s is not a method of %s", method, obj->
ClassName());
1473 TString Method = alt_method_name;
1474 if (Method ==
"") Method = method;
1498 ::Info(
"KVBase::CombineFiles",
"Copying all objects from %s and %s ===> into new file %s", file1, file2, newfilename);
1560 cout <<
"/----------------------------------------------------------------------\\" << endl;
1561 cout <<
"| Welcome to KaliVeda " <<
GetKVVersion() <<
" github:kaliveda-dev/kaliveda |" << endl;
1562 cout <<
"| (c) 2002-2022, The KaliVeda development team |" << endl;
1563 cout <<
"| |" << endl;
1565 #ifdef WITH_GIT_INFOS
1568 printf(
"| From %-63s |\n", gitinfo.
Data());
1570 cout <<
"| See http://indra.in2p3.fr/kaliveda for help |" << endl;
1571 cout <<
"\\----------------------------------------------------------------------/" << endl << endl;
1677 else if (val < func->GetMinimum(
xmin,
xmax)) {
1704 printf(
"Warning in <%s>: Method is deprecated in v%s and will be removed in future.\n%s\n",
Bool_t SearchFile(const Char_t *name, TString &fullpath, int ndirs,...)
Search for file in an arbitrary number of locations, return kTRUE if file found and put full path to ...
void AssignAndDelete(TString &target, char *tobedeleted)
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
char * StrDup(const char *str)
R__EXTERN TSystem * gSystem
Base class for KaliVeda framework.
static TString fWorkingDirectory
user working directory for e.g. database files
static UInt_t fNbObj
Total number of KaliVeda objects (actually counts number of calls to default ctor)
UInt_t fNumber
for numbering objects
static Bool_t FindClassSourceFiles(const Char_t *class_name, KVString &imp_file, KVString &dec_file, const Char_t *dir_name=".")
static const Char_t * GetBINDIRFilePath(const Char_t *namefile="")
static void OpenTempFile(TString &base, std::ofstream &fp)
static const Char_t * GetDATADIRFilePath(const Char_t *namefile="")
static const Char_t * GetDATABASEFilePath()
static const Char_t * GetKVBuildDate()
Returns KaliVeda build date.
static const Char_t * FindFile(const Char_t *search, TString &wfil)
static const Char_t * GetINCDIRFilePath(const Char_t *namefile="")
static const Char_t * gitCommit()
Returns last git commit of sources.
static const Char_t * GetWORKDIRFilePath(const Char_t *namefile="")
void init()
Default initialisation.
static Bool_t FindExecutable(TString &exec, const Char_t *path="$(PATH)")
static const Char_t * GetKVBuildUser()
Returns username of person who performed build.
static void BackupFileWithDate(const Char_t *path)
static void ReadConfigFiles()
static const Char_t * gitBranch()
Returns git branch of sources.
static const Char_t * GetListOfPluginURIs(const Char_t *base)
TString fLabel
label for the object
virtual void Clear(Option_t *opt="")
Clear object properties : name, type/title, number, label.
KVBase()
Default constructor.
static const Char_t * GetListOfPlugins(const Char_t *base)
static Bool_t fEnvIsInit
set when environment is initialised
static Bool_t AreEqual(Double_t x, Double_t y, Long64_t maxdif=1)
Comparison between two 64-bit floating-point values.
KVBase & operator=(const KVBase &)
copy assignment operator
static void CombineFiles(const Char_t *file1, const Char_t *file2, const Char_t *newfilename, Bool_t keep=kTRUE)
const Char_t * GetLabel() const
const Char_t * GetType() const
static const Char_t * GetTEMPLATEDIRFilePath(const Char_t *namefile="")
static const Char_t * GetKVSourceDir()
Returns top-level directory of source tree used for build.
static void InitEnvironment()
virtual void Print(Option_t *option="") const
static const Char_t * GetDataSetEnv(const Char_t *dataset, const Char_t *type, const Char_t *defval)
static const Char_t * GetKVBuildTime()
Returns KaliVeda build date.
static void PrintSplashScreen()
Prints welcome message and infos on version etc.
static const Char_t * GetLIBDIRFilePath(const Char_t *namefile="")
static const Char_t * GetExampleFilePath(const Char_t *library, const Char_t *namefile)
Return full path to example file for given library (="KVMultiDet", "BackTrack", etc....
Double_t ProtectedGetX(const TF1 *func, Double_t val, int &status, Double_t xmin=0.0, Double_t xmax=0.0) const
static const Char_t * GetKVBuildDir()
Returns top-level directory used for build.
static Bool_t SearchAndOpenKVFile(const Char_t *name, std::ifstream &file, const Char_t *kvsubdir="", KVLockfile *locks=0)
static void ReadGUIMimeTypes()
static Bool_t IsThisAPlugin(const TString &uri, TString &base)
virtual TObject * GetObject() const
static void GetTempFileName(TString &base)
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
static const Char_t * GetKVBuildType()
Returns KaliVeda build type (cmake build: Release, Debug, RelWithDebInfo, ...)
static const Char_t * GetPluginURI(const Char_t *base, const Char_t *plugin)
static const Char_t * GetETCDIRFilePath(const Char_t *namefile="")
static Bool_t OpenContextMenu(const char *method, TObject *obj, const char *alt_method_name="")
virtual void Copy(TObject &) const
Make a copy of this object.
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
static const Char_t * GetKVVersion()
Returns KaliVeda version string.
static void Deprecated(const char *method, const char *advice)
Interface to (Linux) system lockfile command.
Bool_t Lock(const Char_t *filename="")
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
KVNamedParameter * GetParameter(Int_t idx) const
return the parameter object with index idx
void SetValue(const Char_t *name, value_type value)
Int_t GetNpar() const
return the number of stored parameters
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const char *classname)=0
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
const char * AsSQLString() const
const char * GetName() const
virtual const char * GetValue(const char *name, const char *dflt) const
virtual Int_t ReadFile(const char *fname, EEnvLevel level)
Bool_t Defined(const char *name) const
THashList * GetTable() const
virtual Double_t GetMinimumX(Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual Double_t GetX(Double_t y, Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual Double_t GetMaximum(Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual Double_t GetMaximumX(Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
virtual Bool_t OutputFile(const char *url, Bool_t force)
virtual Bool_t Merge(Bool_t=kTRUE)
virtual Bool_t AddFile(const char *url, Bool_t cpProgress=kTRUE)
virtual TObject * FindObject(const char *name) const
virtual const char * GetName() const
virtual void Copy(TObject &named) const
virtual void Clear(Option_t *option="")
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
Int_t CheckPlugin() const
virtual void SetSeed(ULong_t seed=0)
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Bool_t MaybeRegexp() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
const char * Data() const
TString & Prepend(char c, Ssiz_t rep=1)
void Form(const char *fmt,...)
TString & Remove(EStripType s, char c)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
virtual TList * GetListOfFiles() const
virtual void AddIncludePath(const char *includePath)
virtual const char * Getenv(const char *env)
virtual char * ConcatFileName(const char *dir, const char *name)
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
virtual int Rename(const char *from, const char *to)
virtual Bool_t IsAbsoluteFileName(const char *dir)
virtual void AddDynamicPath(const char *pathname)
virtual char * ExpandPathName(const char *path)
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
virtual void Setenv(const char *name, const char *value)
virtual const char * HomeDirectory(const char *userName=nullptr)
virtual int Unlink(const char *name)
virtual const char * TempDirectory() const
RooCmdArg Label(const char *str)