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;
154 SetBit(kIsKaliVedaObject);
220 std::lock_guard<std::mutex> lk(_kvbase_mutex);
230 TString libdir = GetLIBDIRFilePath();
236 TString incdir = GetINCDIRFilePath();
244 #ifdef WITH_GNU_INSTALL
246 fWorkingDirectory =
gEnv->
GetValue(
"KaliVeda.WorkingDirectory",
"$(HOME)/.kaliveda");
251 fWorkingDirectory = KV_ROOT;
283 TString tmp = GetETCDIRFilePath(
"config.files");
285 conflist.open(tmp.
Data());
286 if (!conflist.good()) {
287 ::Fatal(
"KVBase::ReadConfigFiles",
"Cannot open %s", tmp.
Data());
291 file.ReadLine(conflist);
294 while (!
file.End()) {
295 tmp = GetETCDIRFilePath(
file.Next().Data());
310 gROOT->GetPluginManager()->LoadHandlersFromEnv(
gEnv);
313 if (!
gROOT->IsBatch()) ReadGUIMimeTypes();
347 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
350 ((
KVBase&) obj).Copy(*
this);
363 if (&other !=
this) {
384 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
397 ((
KVBase&) obj).SetNumber(fNumber);
398 ((
KVBase&) obj).SetLabel(fLabel);
407 cout <<
"KVBase object: Name=" <<
GetName() <<
" Type=" <<
GetType();
498 va_start(args, ndirs);
500 for (; ndirs; ndirs--) {
556 if (strcmp(kvsubdir,
"")) {
561 kvfile_dir = kvsubdir;
566 return SearchFile(
name, fullpath, 3, kvfile_dir.
Data(),
659 dbfile.
open(fullpath);
718 else if (strcmp(kvsubdir,
"")) {
767 TString backup = fullpath +
"." + date;
770 if (lf1.Lock() && lf2.
Lock()) {
772 printf(
"Info in <KVBase::BackupFileWithDate(const Char_t *)> : Existing file %s renamed %s\n",
830 fp.open(base.
Data());
859 base = tmp1 + (++lnow);
947 #ifdef WITH_GIT_INFOS
955 return kaliveda::git_infos::KV_GIT_BRANCH.c_str();
966 return kaliveda::git_infos::KV_GIT_COMMIT.c_str();
1003 TString spath(path), backup(exec), backup2(exec), expandexec(exec);
1014 if (!expandexec.
EndsWith(
".exe")) {
1015 expandexec +=
".exe";
1028 if (!backup.EndsWith(
".exe")) {
1050 #ifdef __WITHOUT_TSYSTEM_FINDFILE
1123 ok_imp = ok_dec =
kFALSE;
1126 for (i = 0; i < impl_alt.
GetNpar(); i++) {
1133 for (i = 0; i < decl_alt.
GetNpar(); i++) {
1139 return (ok_imp && ok_dec);
1182 while ((er = (
TEnvRec*) next())) {
1184 if ((s = strstr(er->
GetName(),
"Plugin."))) {
1193 if (strcmp(s, base))
continue;
1198 if (regexp.
IsNull())
break;
1199 TString clss = strtok(0,
"; ");
1200 if (clss.
IsNull())
break;
1201 TString plugin = strtok(0,
"; ");
1202 if (plugin.
IsNull())
break;
1203 TString ctor = strtok(0,
";\"");
1205 ctor = strtok(0,
";\"");
1206 if (clss == derived) {
1262 while ((er = (
TEnvRec*) next())) {
1264 if ((s = strstr(er->
GetName(),
"Plugin."))) {
1273 if (strcmp(s, base))
continue;
1278 if (regexp.
IsNull())
break;
1279 TString clss = strtok(0,
"; ");
1280 if (clss.
IsNull())
break;
1281 TString plugin = strtok(0,
"; ");
1282 if (plugin.
IsNull())
break;
1283 TString ctor = strtok(0,
";\"");
1285 ctor = strtok(0,
";\"");
1326 while (!plugs.
End()) {
1327 if (tmp !=
"") tmp +=
" ";
1350 while ((er = (
TEnvRec*) next())) {
1357 while (!erval.
End()) {
1396 if (mimetypes !=
"") {
1398 mimetypes.
Begin(
" ");
1399 while (!mimetypes.
End()) {
1445 if (A == B)
return true;
1458 if (Aint < 0) Aint = zero.i - Aint;
1459 if (Bint < 0) Bint = zero.i - Bint;
1463 if (intDiff <= maxdif)
return true;
1491 obj->
Warning(
"OpenContextMenu",
"%s is not a method of %s", method, obj->
ClassName());
1494 TString Method = alt_method_name;
1495 if (Method ==
"") Method = method;
1519 ::Info(
"KVBase::CombineFiles",
"Copying all objects from %s and %s ===> into new file %s", file1, file2, newfilename);
1581 cout <<
"/----------------------------------------------------------------------\\" << endl;
1582 cout <<
"| Welcome to KaliVeda v" <<
GetKVVersion() <<
" gitlab.in2p3.fr/kaliveda-dev/kaliveda |" << endl;
1583 cout <<
"| (c) 2002-2024, The KaliVeda development team |" << endl;
1584 cout <<
"| |" << endl;
1586 #ifdef WITH_GIT_INFOS
1589 printf(
"| From %-63s |\n", gitinfo.
Data());
1591 cout <<
"| See https://kaliveda.in2p3.fr for help |" << endl;
1592 cout <<
"\\----------------------------------------------------------------------/" << endl << endl;
1637 else if (val < func->GetMinimum(
xmin,
xmax)) {
1656 va_start(ap,
va_(fmt));
1657 fprintf(stderr,
"%s",
"\033[1;38;5;202m");
1659 fprintf(stderr,
"%s",
"\033[0m");
1669 va_start(ap,
va_(fmt));
1670 fprintf(stderr,
"%s",
"\033[1;38;5;196m");
1672 fprintf(stderr,
"%s",
"\033[0m");
1691 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()
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.
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()