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