Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
Public Member Functions | Static Public Member Functions | Friends | List of all members
JSUPPORT::JMeta Struct Reference

Auxiliary class for ROOT I/O of application specific meta data. More...

#include <JMeta.hh>

Inheritance diagram for JSUPPORT::JMeta:
std::map< std::string, std::string > JSUPPORT::JMetaOld_t

Public Member Functions

 JMeta ()
 Default constructor. More...
 
 JMeta (const int argc, const char *const argv[])
 Constructor. More...
 
 operator JComment_t () const
 Type conversion operator. More...
 
std::string toString () const
 Convert meta data to string. More...
 

Static Public Member Functions

static void copy (const char *const file_name, TFile &out)
 Copy meta data. More...
 
static const JEquationParametersgetEquationParameters ()
 Get equation parameters. More...
 
static JMeta valueOf (const std::string &buffer)
 Extract meta data. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const JMeta &meta)
 Write meta data to output. More...
 

Detailed Description

Auxiliary class for ROOT I/O of application specific meta data.

Definition at line 70 of file JMeta.hh.

Constructor & Destructor Documentation

◆ JMeta() [1/2]

JSUPPORT::JMeta::JMeta ( )
inline

Default constructor.

Definition at line 76 of file JMeta.hh.

77  {}

◆ JMeta() [2/2]

JSUPPORT::JMeta::JMeta ( const int  argc,
const char *const  argv[] 
)
inline

Constructor.

Parameters
argcnumber of command line arguments
argvarray of command line arguments

Definition at line 86 of file JMeta.hh.

87  {
88  using namespace std;
89  using namespace JPP;
90 
91  if (argc > 0) {
92 
93  (*this)[application_t] = getFilename(argv[0]);
94  (*this)[GITrelease_t] = getGITVersion();
95  (*this)[ROOTrelease_t] = ROOT_RELEASE;
96  (*this)[namespace_t] = getNamespace();
97  (*this)[command_t] = MAKE_STRING(getPath(PATH, argv[0]) << '/' << argv[0]);
98 
99  for (int i = 1; i != argc; ++i) {
100  if (get_number_of_tokens(argv[i]) == 1)
101  (*this)[command_t] += MAKE_STRING(' ' << argv[i]);
102  else
103  (*this)[command_t] += MAKE_STRING(' ' << "\\\"" << argv[i] << "\\\"");
104  }
105 
106  const JUTSName buffer;
107 
108  (*this)[system_t] = MAKE_STRING(""
109  << buffer.sysname << ' '
110  << buffer.nodename << ' '
111  << buffer.release << ' '
112  << buffer.version << ' '
113  << buffer.machine);
114  }
115  }
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:63
static const char *const PATH
binary file paths
Definition: JeepToolkit.hh:35
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:128
std::string getGITVersion(const std::string &tag)
Get GIT version for given GIT tag.
std::string getNamespace(const std::string &type_name)
Get name space, i.e. part before JEEP::TYPENAME_SEPARATOR.
Definition: JeepToolkit.hh:270
std::string getPath(const std::string &file_name)
Get path, i.e. part before last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:148
size_t get_number_of_tokens(const std::string &buffer)
Count number of white space separated tokens.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
static const char *const command_t
Linux command.
Definition: JMeta.hh:63
static const char *const GITrelease_t
GIT release.
Definition: JMeta.hh:60
static const char *const application_t
Definition of meta data parameters.
Definition: JMeta.hh:58
static const char *const namespace_t
name space
Definition: JMeta.hh:62
static const char *const ROOTrelease_t
ROOT release.
Definition: JMeta.hh:61
static const char *const system_t
system information
Definition: JMeta.hh:64
Definition: JSTDTypes.hh:14
Auxiliary class for operating system information.
Definition: JUTSName.hh:23

Member Function Documentation

◆ operator JComment_t()

JSUPPORT::JMeta::operator JComment_t ( ) const
inline

Type conversion operator.

Returns
comment

Definition at line 123 of file JMeta.hh.

124  {
125  JComment_t comment;
126 
127  for (const_iterator i = this->begin(); i != this->end(); ++i) {
128  comment.push_back(i->first + ' ' + i->second);
129  }
130 
131  return comment;
132  }

◆ copy()

void JSUPPORT::JMeta::copy ( const char *const  file_name,
TFile &  out 
)
static

Copy meta data.

Parameters
file_namename of input file
outoutput file

Definition at line 421 of file JMeta.hh.

422  {
423  using namespace JPP;
424 
425  JRootFileReader<JMeta> in(file_name);
426 
427  while (in.hasNext()) {
428 
429  const JMeta* p = in.next();
430 
431  putObject(out, *p);
432  }
433  }
ROOT file reader.
bool putObject(TDirectory &dir, const JMeta &meta)
Write meta data to ROOT directory.
Definition: JMeta.hh:370
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:72

◆ getEquationParameters()

static const JEquationParameters& JSUPPORT::JMeta::getEquationParameters ( )
inlinestatic

Get equation parameters.

Returns
equation parameters

Definition at line 149 of file JMeta.hh.

150  {
151  static const JEquationParameters parameters("=", "\n", "", "");
152 
153  return parameters;
154  }
Simple data structure to support I/O of equations (see class JLANG::JEquation).

◆ valueOf()

static JMeta JSUPPORT::JMeta::valueOf ( const std::string &  buffer)
inlinestatic

Extract meta data.

Parameters
buffermeta data
Returns
meta data

Definition at line 163 of file JMeta.hh.

164  {
165  using namespace std;
166  using namespace JPP;
167 
168  JMeta meta;
169 
170  istringstream is(buffer);
171 
173 
174  for (JEquation equation; is >> equation; ) {
175  meta[equation.getKey()] = equation.getValue();
176  }
177 
178  return meta;
179  }
General purpose equation class.
Definition: JEquation.hh:47
JLANG::JEquationFacet setequation
Type definition of stream manipulator for equational I/O.
static const JEquationParameters & getEquationParameters()
Get equation parameters.
Definition: JMeta.hh:149

◆ toString()

std::string JSUPPORT::JMeta::toString ( ) const
inline

Convert meta data to string.

Returns
string

Definition at line 187 of file JMeta.hh.

188  {
189  using namespace std;
190  using namespace JPP;
191 
192  ostringstream os;
193 
195 
196  for (JMeta::const_iterator i = this->begin(); i != this->end(); ++i) {
197  os << JEquation::make_equation(i->first, i->second);
198  }
199 
200  return os.str();
201  }

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const JMeta meta 
)
friend

Write meta data to output.

Parameters
outoutput stream
metameta data
Returns
output stream

Definition at line 211 of file JMeta.hh.

212  {
213  using namespace std;
214 
215  const_iterator p = meta.find(application_t);
216 
217  if (p != meta.end()) {
218  for (const_iterator i = meta.begin(); i != meta.end(); ++i) {
219  if (i != p) {
220  out << p->second << ' ' << i->second << endl;
221  }
222  }
223  }
224 
225  return out;
226  }

The documentation for this struct was generated from the following file: