diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt index 4ea66c94087d8b2b05c39026ac7c46d71b3ba3a9..da2a23efd3ff425bd30e5e3f93feb0bdc2738da9 100644 --- a/Examples/CMakeLists.txt +++ b/Examples/CMakeLists.txt @@ -3,13 +3,20 @@ gaudi_subdir(Examples v0r0) set(Examples_srcs src/HelloWorld/*.cpp + src/FirstSvc/*.cpp + src/SecondAlg/*.cpp ) +# Headers and Libraries + +gaudi_install_headers(Examples) + +# Modules gaudi_add_module(Examples ${Examples_srcs} INCLUDE_DIRS GaudiKernel LINK_LIBRARIES GaudiKernel ) -# Examples +# Unit tests gaudi_add_test(HelloAlg FRAMEWORK options/helloalg.py) \ No newline at end of file diff --git a/Examples/Examples/IFirstSvc.h b/Examples/Examples/IFirstSvc.h new file mode 100644 index 0000000000000000000000000000000000000000..a8634cfa4ad7ded09cf6614b45342265f8356c39 --- /dev/null +++ b/Examples/Examples/IFirstSvc.h @@ -0,0 +1,14 @@ +#ifndef IFirstSvc_h +#define IFirstSvc_h + +#include "GaudiKernel/IService.h" + +class IFirstSvc: virtual public IInterface { +public: + DeclareInterfaceID(IFirstSvc, 0, 1); // major/minor version + + virtual void shoot() = 0; + +}; + +#endif diff --git a/Examples/src/FirstSvc/FirstSvc.cpp b/Examples/src/FirstSvc/FirstSvc.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f188a8e264227e51ab1de0f80e2515fbb76b51ad --- /dev/null +++ b/Examples/src/FirstSvc/FirstSvc.cpp @@ -0,0 +1,25 @@ +#include "FirstSvc.h" + +DECLARE_COMPONENT(FirstSvc) + +StatusCode +FirstSvc::initialize() { + StatusCode sc = Service::initialize(); + + return sc; +} + +StatusCode +FirstSvc::finalize() { + // clear or reset + + // + StatusCode sc = Service::finalize(); + return sc; +} + +void +FirstSvc::shoot() { + msg() << "shoot it." << endmsg; + +} diff --git a/Examples/src/FirstSvc/FirstSvc.h b/Examples/src/FirstSvc/FirstSvc.h new file mode 100644 index 0000000000000000000000000000000000000000..25315673afa66b57ddeb6924aa5f4bc2434f3acb --- /dev/null +++ b/Examples/src/FirstSvc/FirstSvc.h @@ -0,0 +1,17 @@ +#ifndef FirstSvc_h +#define FirstSvc_h + +#include "Examples/IFirstSvc.h" +#include <GaudiKernel/Service.h> + +class FirstSvc: public extends<Service, IFirstSvc> { +public: + using extends::extends; + + StatusCode initialize() override; + StatusCode finalize() override; + + void shoot() override; +}; + +#endif diff --git a/Examples/src/SecondAlg/SecondAlg.cpp b/Examples/src/SecondAlg/SecondAlg.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fc7f16902bcaceae031f01fa324720967a105e12 --- /dev/null +++ b/Examples/src/SecondAlg/SecondAlg.cpp @@ -0,0 +1,36 @@ +#include "SecondAlg.h" + +DECLARE_COMPONENT(SecondAlg) + +SecondAlg::SecondAlg(const std::string& name, ISvcLocator* pSvcLocator) +: Algorithm(name, pSvcLocator) { + +} + +StatusCode +SecondAlg::initialize() { + StatusCode sc; + + info() << "Retrieving the FirstSvc... " << endmsg; + + m_firstsvc = service("FirstSvc"); + + return sc; +} + +StatusCode +SecondAlg::execute() { + StatusCode sc; + + m_firstsvc->shoot(); + + return sc; +} + +StatusCode +SecondAlg::finalize() { + StatusCode sc; + return sc; +} + + diff --git a/Examples/src/SecondAlg/SecondAlg.h b/Examples/src/SecondAlg/SecondAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..e96306c826dc503a2c6c6cc3f11b74608ca81baf --- /dev/null +++ b/Examples/src/SecondAlg/SecondAlg.h @@ -0,0 +1,24 @@ +#ifndef SecondAlg_h +#define SecondAlg_h + +#include <GaudiKernel/Algorithm.h> +#include <GaudiKernel/Property.h> + +#include "Examples/IFirstSvc.h" + +// The second algorithm shows how to invoke the services. + +class SecondAlg: public Algorithm { +public: + SecondAlg(const std::string& name, ISvcLocator* pSvcLocator); + + StatusCode initialize() override; + StatusCode execute() override; + StatusCode finalize() override; + +private: + SmartIF<IFirstSvc> m_firstsvc; +}; + + +#endif