26 #include "KVNameValueList.h"
27 #include "KVSystemDirectory.h"
28 #include "KVVersion.h"
30 #include "KVGitInfo.h"
52 std::mutex _kvbase_mutex;
61 if (strcmp(namefile,
""))
return Form(
"%s/%s", kaliveda::build_infos::ETCDIR.c_str(), namefile);
62 return kaliveda::build_infos::ETCDIR.c_str();
70 if (strcmp(namefile,
""))
return Form(
"%s/%s", kaliveda::build_infos::DATADIR.c_str(), namefile);
71 return kaliveda::build_infos::DATADIR.c_str();
79 if (strcmp(namefile,
""))
return Form(
"%s/%s", kaliveda::build_infos::TEMPLATEDIR.c_str(), namefile);
80 return kaliveda::build_infos::TEMPLATEDIR.c_str();
88 return Form(
"%s/db", fWorkingDirectory.Data());
96 if (strcmp(namefile,
""))
return Form(
"%s/%s", kaliveda::build_infos::LIBDIR.c_str(), namefile);
97 return kaliveda::build_infos::LIBDIR.c_str();
105 if (strcmp(namefile,
""))
return Form(
"%s/%s", kaliveda::build_infos::INCDIR.c_str(), namefile);
106 return kaliveda::build_infos::INCDIR.c_str();
114 if (strcmp(namefile,
""))
return Form(
"%s/%s", kaliveda::build_infos::BINDIR.c_str(), namefile);
115 return kaliveda::build_infos::BINDIR.c_str();
123 if (strcmp(namefile,
""))
return Form(
"%s/%s", fWorkingDirectory.Data(), namefile);
124 return fWorkingDirectory;
140 SetBit(kIsKaliVedaObject);
206 std::lock_guard<std::mutex> lk(_kvbase_mutex);
216 TString libdir = GetLIBDIRFilePath();
222 TString incdir = GetINCDIRFilePath();
230 #ifdef WITH_GNU_INSTALL
232 fWorkingDirectory =
gEnv->
GetValue(
"KaliVeda.WorkingDirectory",
"$(HOME)/.kaliveda");
237 fWorkingDirectory = KV_ROOT;
269 TString tmp = GetETCDIRFilePath(
"config.files");
271 conflist.open(tmp.
Data());
272 if (!conflist.good()) {
273 ::Fatal(
"KVBase::ReadConfigFiles",
"Cannot open %s", tmp.
Data());
277 file.ReadLine(conflist);
280 while (!
file.End()) {
281 tmp = GetETCDIRFilePath(
file.Next().Data());
294 gROOT->GetPluginManager()->LoadHandlersFromEnv(
gEnv);
297 if (!
gROOT->IsBatch()) ReadGUIMimeTypes();
331 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
334 ((
KVBase&) obj).Copy(*
this);
347 if (&other !=
this) {
368 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
381 ((
KVBase&) obj).SetNumber(fNumber);
382 ((
KVBase&) obj).SetLabel(fLabel);
391 cout <<
"KVBase object: Name=" <<
GetName() <<
" Type=" <<
GetType();
482 va_start(args, ndirs);
484 for (; ndirs; ndirs--) {
540 if (strcmp(kvsubdir,
"")) {
545 kvfile_dir = kvsubdir;
550 return SearchFile(
name, fullpath, 3, kvfile_dir.
Data(),
643 dbfile.
open(fullpath);
702 else if (strcmp(kvsubdir,
"")) {
751 TString backup = fullpath +
"." + date;
754 if (lf1.Lock() && lf2.
Lock()) {
756 printf(
"Info in <KVBase::BackupFileWithDate(const Char_t *)> : Existing file %s renamed %s\n",
814 fp.open(base.
Data());
843 base = tmp1 + (++lnow);
856 return kaliveda::build_infos::KV_VERSION.c_str();
868 return kaliveda::build_infos::KV_BUILD_USER.c_str();
880 return kaliveda::build_infos::KV_BUILD_DATE.c_str();
891 return kaliveda::build_infos::KV_BUILD_TIME.c_str();
903 return kaliveda::build_infos::KV_BUILD_TYPE.c_str();
915 return kaliveda::build_infos::KV_SOURCE_DIR.c_str();
927 return kaliveda::build_infos::KV_BUILD_DIR.c_str();
931 #ifdef WITH_GIT_INFOS
939 return kaliveda::git_infos::KV_GIT_BRANCH.c_str();
950 return kaliveda::git_infos::KV_GIT_COMMIT.c_str();
987 TString spath(path), backup(exec), backup2(exec), expandexec(exec);
999 expandexec +=
".exe";
1012 if (!backup.EndsWith(
".exe")) {
1034 #ifdef __WITHOUT_TSYSTEM_FINDFILE
1107 ok_imp = ok_dec =
kFALSE;
1110 for (i = 0; i < impl_alt.
GetNpar(); i++) {
1117 for (i = 0; i < decl_alt.
GetNpar(); i++) {
1123 return (ok_imp && ok_dec);
1166 while ((er = (
TEnvRec*) next())) {
1168 if ((s = strstr(er->
GetName(),
"Plugin."))) {
1177 if (strcmp(s, base))
continue;
1182 if (regexp.
IsNull())
break;
1183 TString clss = strtok(0,
"; ");
1184 if (clss.
IsNull())
break;
1185 TString plugin = strtok(0,
"; ");
1186 if (plugin.
IsNull())
break;
1187 TString ctor = strtok(0,
";\"");
1189 ctor = strtok(0,
";\"");
1190 if (clss == derived) {
1246 while ((er = (
TEnvRec*) next())) {
1248 if ((s = strstr(er->
GetName(),
"Plugin."))) {
1257 if (strcmp(s, base))
continue;
1262 if (regexp.
IsNull())
break;
1263 TString clss = strtok(0,
"; ");
1264 if (clss.
IsNull())
break;
1265 TString plugin = strtok(0,
"; ");
1266 if (plugin.
IsNull())
break;
1267 TString ctor = strtok(0,
";\"");
1269 ctor = strtok(0,
";\"");
1310 while (!plugs.
End()) {
1311 if (tmp !=
"") tmp +=
" ";
1334 while ((er = (
TEnvRec*) next())) {
1341 while (!erval.
End()) {
1380 if (mimetypes !=
"") {
1382 mimetypes.
Begin(
" ");
1383 while (!mimetypes.
End()) {
1429 if (A == B)
return true;
1442 if (Aint < 0) Aint = zero.i - Aint;
1443 if (Bint < 0) Bint = zero.i - Bint;
1447 if (intDiff <= maxdif)
return true;
1475 obj->
Warning(
"OpenContextMenu",
"%s is not a method of %s", method, obj->
ClassName());
1478 TString Method = alt_method_name;
1479 if (Method ==
"") Method = method;
1503 ::Info(
"KVBase::CombineFiles",
"Copying all objects from %s and %s ===> into new file %s", file1, file2, newfilename);
1565 cout <<
"/----------------------------------------------------------------------\\" << endl;
1566 cout <<
"| Welcome to KaliVeda v" <<
GetKVVersion() <<
" gitlab.in2p3.fr/kaliveda-dev/kaliveda |" << endl;
1567 cout <<
"| (c) 2002-2024, The KaliVeda development team |" << endl;
1568 cout <<
"| |" << endl;
1570 #ifdef WITH_GIT_INFOS
1573 printf(
"| From %-63s |\n", gitinfo.
Data());
1575 cout <<
"| See https://kaliveda.in2p3.fr for help |" << endl;
1576 cout <<
"\\----------------------------------------------------------------------/" << endl << endl;
1621 else if (val < func->GetMinimum(
xmin,
xmax)) {
1648 printf(
"Warning in <%s>: Method is deprecated in v%s and will be removed in future.\n%s\n",
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
char * StrDup(const char *str)
void AssignAndDelete(TString &target, char *tobedeleted)
R__EXTERN TSystem * gSystem
Base class for KaliVeda framework.
static TString fWorkingDirectory
user working directory for e.g. database files
void Clear(Option_t *opt="") override
Clear object properties : name, type/title, number, label.
UInt_t fNumber
for numbering objects
virtual const Char_t * GetType() const
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
KVBase()
Default constructor.
static int GetKVMajorVersion()
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
static Bool_t FindClassSourceFiles(const KVString &class_name, KVString &imp_file, KVString &dec_file, const KVString &dir_name=".")
static const Char_t * GetTEMPLATEDIRFilePath(const Char_t *namefile="")
static const Char_t * GetKVSourceDir()
Returns top-level directory of source tree used for build.
void Copy(TObject &) const override
Make a copy of this object.
static void InitEnvironment()
void Print(Option_t *option="") const override
static const Char_t * GetKVBuildTime()
Returns KaliVeda build time.
static int GetKVMinorVersion()
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 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="")
static Bool_t SearchAndOpenKVFile(const Char_t *name, KVSQLite::database &dbfile, const Char_t *kvsubdir="")
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
Interface to ROOT SQLite database backend.
void open(const TString &dbfile)
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
Extension of ROOT TSystemDirectory class, handling browsing directories on disk.
TList * GetListOfFiles() const override
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=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
Int_t ReadBuffer(TBuffer &b, void *pointer)
TMethod * GetMethodAllAny(const char *method)
Int_t WriteBuffer(TBuffer &b, void *pointer, const char *info="")
const char * AsSQLString() const
const char * GetName() const override
THashList * GetTable() 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
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)
TObject * FindObject(const char *name) const override
void Copy(TObject &named) const override
const char * GetName() const override
void Streamer(TBuffer &) override
void Clear(Option_t *option="") override
TClass * IsA() const override
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual TClass * IsA() 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
const char * Data() const
Bool_t MaybeRegexp() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) 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 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)
RVec< PromoteType< T > > abs(const RVec< T > &v)
void EnableThreadSafety()