Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / include / details / ie_irelease.hpp
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 /**
6  * @brief A header file for the Inference Engine plugins destruction mechanism
7  * @file ie_irelease.hpp
8  */
9 #pragma once
10
11 #include "ie_no_copy.hpp"
12 #include <memory>
13
14 namespace InferenceEngine {
15 namespace details {
16 /**
17  * @brief This class is used for objects allocated by a shared module (in *.so)
18  */
19 class IRelease : public no_copy {
20 public:
21     /**
22      * @brief Releases current allocated object and all related resources.
23      * Once this method is called, the pointer to this interface is no longer valid
24      */
25     virtual void Release() noexcept = 0;
26
27  protected:
28     /**
29      * @brief Default destructor
30      */
31     ~IRelease() override = default;
32 };
33
34
35
36 template <class T> inline std::shared_ptr<T> shared_from_irelease(T * ptr) {
37     std::shared_ptr<T> pointer(ptr, [](IRelease *p) {
38         p->Release();
39     });
40     return pointer;
41 }
42
43 }  // namespace details
44 }  // namespace InferenceEngine