ATLAS Offline Software
Loading...
Searching...
No Matches
SealSharedLib.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
14
15#ifndef CXXUTILS_SEAL_SHAREDLIB_H // wlav SEAL_BASE_SHARED_LIBRARY_H
16#define CXXUTILS_SEAL_SHAREDLIB_H // wlav SEAL_BASE_SHARED_LIBRARY_H
17
18
20//# include "SealBase/SharedLibraryError.h" wlav
21//# include "SealBase/Callback.h" wlav
22# include <string>
23# include <list>
24# include <exception> // wlav
25
26//namespace seal { wlav
27namespace Athena { // wlav
28
29
30
31// wlav from SealBase/Callback.h
32template <class T1>
34{
35public:
36 Callback1Rep (void) : m_refs (0) { }
37 virtual ~Callback1Rep (void) { }
38
39 virtual void call (T1) = 0;
40 virtual bool equal (const Callback1Rep *x) const = 0;
41
42 void ref (void) { ++m_refs; }
43 void unref (void) { if (--m_refs == 0) delete this; }
44
45private:
46 int m_refs;
47};
48
49template <class T1>
51{
52public:
53 Callback1 (Callback1Rep<T1> *implementation = 0);
55 ~Callback1 (void);
57
58 bool operator== (const Callback1 &x) const;
59 /**/ operator bool (void) const;
60 void operator() (T1);
61
62private:
64};
65
66template <class T1, class T2>
67class CallbackImpF11 : public Callback1Rep<T1>
68{
70public:
71 CallbackImpF11 (void (*function) (T1, T2),
72 const T2 &fill_2)
73 : m_function (function),
74 m_fill_2 (fill_2)
75 { }
76
77 virtual void call (T1 a)
78 { (*m_function) (a, m_fill_2); }
79
80 virtual bool equal (const Callback1Rep<T1> *other) const
81 { const self *x = dynamic_cast<const self *> (other);
82 return x && x->m_function == m_function && x->m_fill_2 == m_fill_2; }
83
84private:
85 void (*m_function) (T1, T2);
87};
88
89template <class T1>
90inline
91Callback1<T1>::Callback1 (Callback1Rep<T1> *implementation /* = 0 */)
92 : m_rep (implementation)
93{ if (m_rep) m_rep->ref (); }
94
95template <class T1>
96inline
98 : m_rep (x.m_rep)
99{ if (m_rep) m_rep->ref (); }
100
101template <class T1>
102inline
104{ if (m_rep) m_rep->unref (); }
105
106template <class T1>
107inline Callback1<T1> &
109{
110 if (m_rep != x.m_rep)
111 {
112 if (m_rep) m_rep->unref ();
113 m_rep = x.m_rep;
114 if (m_rep) m_rep->ref ();
115 }
116 return *this;
117}
118
119template <class T1>
120inline bool
122{ return m_rep == x.m_rep || (m_rep && x.m_rep && m_rep->equal (x.m_rep)); }
123
124template <class T1>
125inline
126Callback1<T1>::operator bool (void) const
127{ return m_rep ? true : false; } // FIXME: for Sun CC 4.2 (no bool)
128
129template <class T1>
130inline void
133
134template <class T1, class T2>
135inline Callback1Rep<T1> *
136CreateCallback (void (*function) (T1, T2),
137 const T2 &fill_2)
138{ return new CallbackImpF11<T1,T2> (function, fill_2); }
139
140
141// wlav modified from SealBase/SharedLibraryError.h
143class SharedLibraryError : public std::exception
144{
145public:
146 SharedLibraryError( const std::string& context, const std::string& cause );
147 virtual ~SharedLibraryError() throw() {}
148
149 virtual const char* what() const throw();
150
151private:
152 std::string m_message;
153};
154
155
158{
159public:
160 typedef void * Data;
161 typedef void (*Function) (void);
162
165 {
166 unsigned long m_text_start; //< Start of text segment
167 unsigned long m_text_end; //< End of text segment
168 unsigned long m_data_start; //< Start of data segment
169 unsigned long m_data_end; //< End of data segment
170 unsigned long m_bss_start; //< Start of common
171 unsigned long m_bss_end; //< End of common
172 const char *m_filename; //< Filename
173 };
174
176
177 static std::string path (void);
178 static void path ATLAS_NOT_THREAD_SAFE (const std::string &path);
179 static std::string libname (const std::string &name);
180 static std::string symname (const std::string &name);
181
182 static SharedLibrary * self (void);
183 static SharedLibrary * load (const std::string &name);
184 static void loaded (InfoHandler &handler);
185
186 void release (void);
187 void abandon (void);
188
189 Data data (const std::string &name, bool mangle = true) const;
190 Function function (const std::string &name, bool mangle = true) const;
191
192protected:
193 SharedLibrary (void *handle);
194 ~SharedLibrary (void);
195
196private:
197 void *m_handle;
198
199 // undefined semantics
201 SharedLibrary &operator= (const SharedLibrary &);
202};
203
204//<<<<<< INLINE PUBLIC FUNCTIONS >>>>>>
205//<<<<<< INLINE MEMBER FUNCTIONS >>>>>>
206
207//} // namespace seal wlav
208} // namespace Athena wlav
209#endif // CXXUTILS_SEAL_SHAREDLIB_H wlav SEAL_BASE_SHARED_LIBRARY_H
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t a
#define x
Define macros for attributes used to control the static checker.
virtual ~Callback1Rep(void)
virtual bool equal(const Callback1Rep *x) const =0
virtual void call(T1)=0
Callback1(const Callback1 &x)
Callback1 & operator=(const Callback1 &x)
Callback1(Callback1Rep< T1 > *implementation=0)
bool operator==(const Callback1 &x) const
Callback1Rep< const LibraryInfo & > * m_rep
CallbackImpF11(void(*function)(T1, T2), const T2 &fill_2)
virtual bool equal(const Callback1Rep< T1 > *other) const
virtual void call(T1 a)
void(* m_function)(T1, T2)
SharedLibraryError(const std::string &context, const std::string &cause)
virtual const char * what() const
SharedLibrary(void *handle)
Protected constructor for initialising a library object.
static SharedLibrary * load(const std::string &name)
Load a shared library and return an object representing it.
void abandon(void)
Abandon a library.
Function function(const std::string &name, bool mangle=true) const
Locate and return a reference to a function symbol called name.
static void loaded(InfoHandler &handler)
Iterate and provide information about all currently loaded shared libraries.
Callback1< const LibraryInfo & > InfoHandler
static void path ATLAS_NOT_THREAD_SAFE(const std::string &path)
static std::string libname(const std::string &name)
Return a shared library name that follows the system conventions for naming shared library.
static std::string path(void)
static std::string symname(const std::string &name)
Transform 'extern "C"' symbol name into a name suitable for lookup in a shared library,...
static SharedLibrary * self(void)
Return a shared library object representing the application itself.
SharedLibrary(const SharedLibrary &)
static std::string release
Definition computils.h:50
Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc....
Callback1Rep< T1 > * CreateCallback(void(*function)(T1, T2), const T2 &fill_2)
STL namespace.
void handler(int sig)
signal handler
Definition rmain.cxx:99
Information about a currently loaded shared library.
#define private