Jpp  debug
the software that should make you happy
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
JAANET::JEventSelector Struct Reference

Event selector. More...

Inheritance diagram for JAANET::JEventSelector:
JEEP::JFunctionAdaptor< JReturn_t, Args > JEEP::JFunctionAdaptorHelper< void(*)(Args...)> JLANG::JSharedCounter

Public Types

typedef JReturn_t(* pF) (Args...)
 Type definition of method. More...
 

Public Member Functions

 JEventSelector ()
 Default constructor. More...
 
JReturn_t operator() (Args... args) const
 Function operation. More...
 
bool is_valid () const
 Check validity of function. More...
 
void reset ()
 Reset function adaptor helper. More...
 
void set (void(*)(Args...) 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 &libso, const std::string &symbol)
 Load function from shared library. More...
 
void reload ()
 Reload 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 Member Functions

static bool select (const Trk &trk, const Evt &evt)
 Default event selection. More...
 

Static Public Attributes

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

Protected Attributes

void * handle
 
void(*)(Args...) function
 
std::string libso
 
std::string symbol
 
int * counter
 

Detailed Description

Event selector.

The default constructor will accept all events.
A different method can dynamically be loaded from a shared library using class JEEP::JFunctionAdaptor.

Definition at line 68 of file JAAnet/JEvD.cc.

Member Typedef Documentation

◆ pF

template<class JReturn_t = void, class ... Args>
typedef JReturn_t(* JEEP::JFunctionAdaptor< JReturn_t, Args >::pF) (Args...)
inherited

Type definition of method.

Definition at line 307 of file JFunctionAdaptor.hh.

Constructor & Destructor Documentation

◆ JEventSelector()

JAANET::JEventSelector::JEventSelector ( )
inline

Default constructor.

Definition at line 87 of file JAAnet/JEvD.cc.

88  {
89  this->function = select;
90  this->symbol = "select";
91  }
static bool select(const Trk &trk, const Evt &evt)
Default event selection.
Definition: JAAnet/JEvD.cc:78

Member Function Documentation

◆ select()

static bool JAANET::JEventSelector::select ( const Trk trk,
const Evt evt 
)
inlinestatic

Default event selection.

Parameters
trktrack
evtevent
Returns
true

Definition at line 78 of file JAAnet/JEvD.cc.

79  {
80  return true;
81  }

◆ operator()()

template<class JReturn_t = void, class ... Args>
JReturn_t JEEP::JFunctionAdaptor< JReturn_t, Args >::operator() ( Args...  args) const
inlineinherited

Function operation.

Parameters
argsarguments
Returns
return value

Definition at line 346 of file JFunctionAdaptor.hh.

347  {
348  return this->function(args...);
349  }

◆ is_valid()

bool JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::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  }

◆ reset()

void JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::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  }

◆ set()

void JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::set ( void(*)(Args...)  pf)
inlineinherited

Set function.

Parameters
pfpointer to function

Definition at line 80 of file JFunctionAdaptor.hh.

81  {
82  reset();
83 
84  function = pf;
85  }
void reset()
Reset function adaptor helper.

◆ get()

void JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::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:712

◆ is_open()

bool JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::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  }

◆ open()

void JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::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  }
void initialise()
Initialise counter.

◆ close()

void JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::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  }

◆ load()

void JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::load ( const std::string &  libso,
const std::string &  symbol 
)
inlineinherited

Load function from shared library.

Parameters
libsofile name
symbolfunction name

Definition at line 168 of file JFunctionAdaptor.hh.

169  {
170  this->libso = libso;
171  this->symbol = symbol;
172 
173  reload();
174  }
void reload()
Reload function from shared library.

◆ reload()

void JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::reload ( )
inlineinherited

Reload function from shared library.

Definition at line 180 of file JFunctionAdaptor.hh.

181  {
182  open(libso.c_str());
183 
184  get(symbol.c_str());
185  }
void open(const char *file_name)
Open file.

◆ initialise()

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  }

◆ attach()

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  }

◆ 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  }

◆ getCount()

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

◆ SEPARATOR

const char JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::SEPARATOR
staticinherited

Separation character between library file name and function name.

Definition at line 39 of file JFunctionAdaptor.hh.

◆ handle

void* JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::handle
protectedinherited

Definition at line 290 of file JFunctionAdaptor.hh.

◆ function

void(*)(Args...) JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::function
protectedinherited

Definition at line 291 of file JFunctionAdaptor.hh.

◆ libso

std::string JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::libso
protectedinherited

Definition at line 292 of file JFunctionAdaptor.hh.

◆ symbol

std::string JEEP::JFunctionAdaptorHelper< void(*)(Args...) >::symbol
protectedinherited

Definition at line 293 of file JFunctionAdaptor.hh.

◆ counter

int* JLANG::JSharedCounter::counter
protectedinherited

Definition at line 94 of file JSharedCounter.hh.


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