Jpp  15.0.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
JRECONSTRUCTION::JQualitySorter Struct Reference

General purpose sorter of fit results. More...

#include <JEvtToolkit.hh>

Inheritance diagram for JRECONSTRUCTION::JQualitySorter:
JEEP::JFunctionAdaptor< JReturn_t, JFirst_t, JSecond_t > JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t)> JLANG::JSharedCounter

Public Types

typedef JFunctionAdaptor< bool,
const JFit &, const JFit & > 
function_adaptor_type
 
typedef function_adaptor_type::pF pF
 

Public Member Functions

 JQualitySorter ()
 Default constructor. More...
 
JReturn_t operator() (JFirst_t first, JSecond_t second) const
 Function operation. More...
 
bool is_valid () const
 Check validity of function. More...
 
void reset ()
 Reset function adaptor helper. More...
 
void set (JReturn_t(*)(JFirst_t, JSecond_t)pf)
 Set function. More...
 
void get (const char *symbol)
 Get function with given name according to specific protocol. More...
 
bool is_open () const
 Check if shared library file is open. More...
 
void open (const char *file_name)
 Open file. More...
 
void close ()
 Close file. More...
 
void load (const std::string &file_name, const std::string &symbol)
 Load function from shared library. More...
 
void load (const std::string &buffer)
 Load function from shared library. More...
 
void initialise ()
 Initialise counter. More...
 
void attach (const JSharedCounter &object)
 Attach this counter to given shared counter object. More...
 
bool detach ()
 Detach. More...
 
const int getCount ()
 Get count. More...
 

Static Public Attributes

static const char SEPARATOR
 Separation character between library file name and function name. More...
 

Protected Attributes

void * handle
 
JReturn_t(*)(JFirst_t, JSecond_t) function
 
int * counter
 

Detailed Description

General purpose sorter of fit results.

The default constructor will sort fit results according the method JRECONSTRUCTION::qualitySorter.
A different method can dynamically be loaded from a (shared) library using class JEEP::JFunctionAdaptor. For the definition of an alternative method, see e.g. quality_sorter.cc

Definition at line 259 of file JReconstruction/JEvtToolkit.hh.

Member Typedef Documentation

Definition at line 262 of file JReconstruction/JEvtToolkit.hh.

typedef function_adaptor_type::pF JRECONSTRUCTION::JQualitySorter::pF

Definition at line 263 of file JReconstruction/JEvtToolkit.hh.

Constructor & Destructor Documentation

JRECONSTRUCTION::JQualitySorter::JQualitySorter ( )
inline

Default constructor.

Definition at line 269 of file JReconstruction/JEvtToolkit.hh.

269  :
271  {}
JFunctionAdaptor< bool, const JFit &, const JFit & > function_adaptor_type
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.

Member Function Documentation

template<class JReturn_t = void, class JFirst_t = void, class JSecond_t = void>
JReturn_t JEEP::JFunctionAdaptor< JReturn_t, JFirst_t, JSecond_t >::operator() ( JFirst_t  first,
JSecond_t  second 
) const
inlineinherited

Function operation.

Parameters
firstfirst argument
secondsecond argument
Returns
return value

Definition at line 401 of file JFunctionAdaptor.hh.

402  {
403  return this->function(first, second);
404  }
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
bool JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t) >::is_valid ( ) const
inlineinherited

Check validity of function.

Returns
true if valid function; else false

Definition at line 56 of file JFunctionAdaptor.hh.

57  {
58  return (function != NULL);
59  }
void JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t) >::reset ( )
inlineinherited

Reset function adaptor helper.

Definition at line 65 of file JFunctionAdaptor.hh.

66  {
67  if (detach()) {
68  close();
69  }
70 
71  function = NULL;
72  }
bool detach()
Detach.
void JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t) >::set ( JReturn_t(*)(JFirst_t, JSecond_t)  pf)
inlineinherited

Set function.

Parameters
pfpointer to function

Definition at line 80 of file JFunctionAdaptor.hh.

81  {
82  close();
83 
84  function = pf;
85  }
void JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t) >::get ( const char *  symbol)
inlineinherited

Get function with given name according to specific protocol.

Parameters
symbolfunction name

Definition at line 93 of file JFunctionAdaptor.hh.

94  {
95  function = NULL;
96 
97  if (handle != NULL) {
98 
99  dlerror(); // reset errors
100 
101  function = (__pF__) dlsym(handle, symbol);
102 
103  const char* error = dlerror();
104 
105  if (error != NULL) {
106  THROW(JFileReadException, error);
107  }
108 
109  } else {
110 
111  THROW(JFileReadException, "Invalid handle.");
112  }
113  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
bool JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t) >::is_open ( ) const
inlineinherited

Check if shared library file is open.

Returns
true if open; else false

Definition at line 121 of file JFunctionAdaptor.hh.

122  {
123  return (handle != NULL);
124  }
void JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t) >::open ( const char *  file_name)
inlineinherited

Open file.

Parameters
file_namefile name

Definition at line 132 of file JFunctionAdaptor.hh.

133  {
134  reset();
135 
136  handle = dlopen(file_name, RTLD_LOCAL | RTLD_LAZY);
137 
138  if (!handle) {
139  THROW(JFileOpenException, dlerror());
140  }
141 
142  initialise();
143  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
void initialise()
Initialise counter.
void JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t) >::close ( )
inlineinherited

Close file.

Note that the file should remain open as long as the library function is used.

Definition at line 151 of file JFunctionAdaptor.hh.

152  {
153  if (handle != NULL) {
154  dlclose(handle);
155  dlclose(handle);
156  }
157 
158  handle = NULL;
159  }
void JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t) >::load ( const std::string &  file_name,
const std::string &  symbol 
)
inlineinherited

Load function from shared library.

Parameters
file_namefile name
symbolfunction name

Definition at line 168 of file JFunctionAdaptor.hh.

169  {
170  open(file_name.c_str());
171 
172  get(symbol.c_str());
173  }
void JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t) >::load ( const std::string &  buffer)
inlineinherited

Load function from shared library.

The input buffer should consist of <file name>SEPARATOR<symbol>.

Parameters
bufferinput

Definition at line 183 of file JFunctionAdaptor.hh.

184  {
185  using namespace std;
186 
187  const string::size_type pos = buffer.rfind(SEPARATOR);
188 
189  if (pos != string::npos) {
190 
191  load(buffer.substr(0,pos).c_str(), buffer.substr(pos+1).c_str());
192 
193  } else {
194 
195  THROW(JParseError, "Missing separator " << SEPARATOR << " in " << buffer);
196  }
197  }
static const char SEPARATOR
Separation character between library file name and function name.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
void load(const std::string &file_name, const std::string &symbol)
Load function from shared library.
void JLANG::JSharedCounter::initialise ( )
inlineinherited

Initialise counter.

Definition at line 33 of file JSharedCounter.hh.

34  {
35  detach();
36 
37  counter = new int(1);
38  }
bool detach()
Detach.
void JLANG::JSharedCounter::attach ( const JSharedCounter object)
inlineinherited

Attach this counter to given shared counter object.

Parameters
objectshared counter

Definition at line 46 of file JSharedCounter.hh.

47  {
48  detach();
49 
50  counter = object.counter;
51 
52  if (counter != NULL) {
53  ++(*counter);
54  }
55  }
bool detach()
Detach.
bool JLANG::JSharedCounter::detach ( )
inlineinherited

Detach.

Returns
true if counter at zero; else false

Definition at line 63 of file JSharedCounter.hh.

64  {
65  if (counter != NULL) {
66 
67  if (--(*counter) == 0) {
68 
69  delete counter;
70 
71  counter = NULL;
72 
73  return true;
74  }
75 
76  counter = NULL;
77  }
78 
79  return false;
80  }
const int JLANG::JSharedCounter::getCount ( )
inlineinherited

Get count.

Returns
count

Definition at line 88 of file JSharedCounter.hh.

89  {
90  return (counter != NULL ? *counter : 0);
91  }

Member Data Documentation

const char JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t) >::SEPARATOR
staticinherited

Separation character between library file name and function name.

Definition at line 39 of file JFunctionAdaptor.hh.

void* JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t) >::handle
protectedinherited

Definition at line 283 of file JFunctionAdaptor.hh.

JReturn_t(*)(JFirst_t, JSecond_t) JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t) >::function
protectedinherited

Definition at line 284 of file JFunctionAdaptor.hh.

int* JLANG::JSharedCounter::counter
protectedinherited

Definition at line 94 of file JSharedCounter.hh.


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