26 #include "KVNameValueList.h"
27 #include "KVSystemDirectory.h"
28 #include "KVVersion.h"
30 #include "KVGitInfo.h"
52 std::mutex _kvbase_mutex;
88 return Form(
"%s/db", fWorkingDirectory.Data());
123 if (strcmp(namefile,
""))
return Form(
"%s/%s", fWorkingDirectory.Data(), namefile);
124 return fWorkingDirectory;
162 SetBit(kIsKaliVedaObject);
228 std::lock_guard<std::mutex> lk(_kvbase_mutex);
238 TString libdir = GetLIBDIRFilePath();
244 TString incdir = GetINCDIRFilePath();
252 #ifdef WITH_GNU_INSTALL
254 fWorkingDirectory =
gEnv->
GetValue(
"KaliVeda.WorkingDirectory",
"$(HOME)/.kaliveda");
259 fWorkingDirectory = KV_ROOT;
291 TString tmp = GetETCDIRFilePath(
"config.files");
293 conflist.open(tmp.
Data());
294 if (!conflist.good()) {
295 ::Fatal(
"KVBase::ReadConfigFiles",
"Cannot open %s", tmp.
Data());
299 file.ReadLine(conflist);
302 while (!
file.End()) {
303 tmp = GetETCDIRFilePath(
file.Next().Data());
318 gROOT->GetPluginManager()->LoadHandlersFromEnv(
gEnv);
321 if (!
gROOT->IsBatch()) ReadGUIMimeTypes();
355 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
358 ((
KVBase&) obj).Copy(*
this);
371 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();
506 va_start(args, ndirs);
508 for (; ndirs; ndirs--) {
564 if (strcmp(kvsubdir,
"")) {
569 kvfile_dir = kvsubdir;
574 return SearchFile(
name, fullpath, 3, kvfile_dir.
Data(),
667 dbfile.
open(fullpath);
726 else if (strcmp(kvsubdir,
"")) {
775 TString backup = fullpath +
"." + date;
778 if (lf1.Lock() && lf2.
Lock()) {
780 printf(
"Info in <KVBase::BackupFileWithDate(const Char_t *)> : Existing file %s renamed %s\n",
838 fp.open(base.
Data());
867 base = tmp1 + (++lnow);
955 #ifdef WITH_GIT_INFOS
963 return kaliveda::git_infos::KV_GIT_BRANCH.c_str();
974 return kaliveda::git_infos::KV_GIT_COMMIT.c_str();
1011 TString spath(path), backup(exec), backup2(exec), expandexec(exec);
1022 if (!expandexec.
EndsWith(
".exe")) {
1023 expandexec +=
".exe";
1036 if (!backup.EndsWith(
".exe")) {
1058 #ifdef __WITHOUT_TSYSTEM_FINDFILE
1131 ok_imp = ok_dec =
kFALSE;
1134 for (i = 0; i < impl_alt.
GetNpar(); i++) {
1141 for (i = 0; i < decl_alt.
GetNpar(); i++) {
1147 return (ok_imp && ok_dec);
1190 while ((er = (
TEnvRec*) next())) {
1192 if ((s = strstr(er->
GetName(),
"Plugin."))) {
1201 if (strcmp(s, base))
continue;
1206 if (regexp.
IsNull())
break;
1207 TString clss = strtok(0,
"; ");
1208 if (clss.
IsNull())
break;
1209 TString plugin = strtok(0,
"; ");
1210 if (plugin.
IsNull())
break;
1211 TString ctor = strtok(0,
";\"");
1213 ctor = strtok(0,
";\"");
1214 if (clss == derived) {
1270 while ((er = (
TEnvRec*) next())) {
1272 if ((s = strstr(er->
GetName(),
"Plugin."))) {
1281 if (strcmp(s, base))
continue;
1286 if (regexp.
IsNull())
break;
1287 TString clss = strtok(0,
"; ");
1288 if (clss.
IsNull())
break;
1289 TString plugin = strtok(0,
"; ");
1290 if (plugin.
IsNull())
break;
1291 TString ctor = strtok(0,
";\"");
1293 ctor = strtok(0,
";\"");
1334 while (!plugs.
End()) {
1335 if (tmp !=
"") tmp +=
" ";
1358 while ((er = (
TEnvRec*) next())) {
1365 while (!erval.
End()) {
1404 if (mimetypes !=
"") {
1406 mimetypes.
Begin(
" ");
1407 while (!mimetypes.
End()) {
1453 if (A == B)
return true;
1466 if (Aint < 0) Aint = zero.i - Aint;
1467 if (Bint < 0) Bint = zero.i - Bint;
1471 if (intDiff <= maxdif)
return true;
1499 obj->
Warning(
"OpenContextMenu",
"%s is not a method of %s", method, obj->
ClassName());
1502 TString Method = alt_method_name;
1503 if (Method ==
"") Method = method;
1527 ::Info(
"KVBase::CombineFiles",
"Copying all objects from %s and %s ===> into new file %s", file1, file2, newfilename);
1589 cout <<
"/----------------------------------------------------------------------\\" << endl;
1590 cout <<
"| Welcome to KaliVeda v" <<
GetKVVersion() <<
" gitlab.in2p3.fr/kaliveda-dev/kaliveda |" << endl;
1591 cout <<
"| (c) 2002-2024, The KaliVeda development team |" << endl;
1592 cout <<
"| |" << endl;
1594 #ifdef WITH_GIT_INFOS
1597 printf(
"| From %-63s |\n", gitinfo.
Data());
1599 cout <<
"| See https://kaliveda.in2p3.fr for help |" << endl;
1600 cout <<
"\\----------------------------------------------------------------------/" << endl << endl;
1645 else if (val < func->GetMinimum(
xmin,
xmax)) {
1673 va_start(ap,
va_(fmt));
1674 fprintf(stderr,
"%s",
"\033[1;38;5;202m");
1676 fprintf(stderr,
"%s",
"\033[0m");
1686 va_start(ap,
va_(fmt));
1687 fprintf(stderr,
"%s",
"\033[1;38;5;196m");
1689 fprintf(stderr,
"%s",
"\033[0m");
1708 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="")
void Error(const char *method, const char *msgfmt,...) const override
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()
static Double_t ProtectedGetX(const TF1 *func, Double_t val, int &status, Double_t xmin=0.0, Double_t xmax=0.0)
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 int GetKVPatchVersion()
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....
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.
void Warning(const char *method, const char *msgfmt,...) const override
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 void DoError(int level, const char *location, const char *fmt, va_list va) const
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()