ie_irelease.hpp
Go to the documentation of this file.
1 // Copyright (C) 2018-2020 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  *
8  * @file ie_irelease.hpp
9  */
10 #pragma once
11 
12 #include <memory>
13 
14 #include "ie_api.h"
15 #include "ie_no_copy.hpp"
16 
17 namespace InferenceEngine {
18 namespace details {
19 /**
20  * @brief This class is used for objects allocated by a shared module (in *.so)
21  */
22 class IRelease : public no_copy {
23 public:
24  /**
25  * @brief Releases current allocated object and all related resources.
26  * Once this method is called, the pointer to this interface is no longer valid
27  */
28  virtual void Release() noexcept = 0;
29 
30 protected:
31  /**
32  * @brief Default destructor
33  */
34  ~IRelease() override = default;
35 };
36 
37 IE_SUPPRESS_DEPRECATED_START
38 
39 template <class T>
40 inline std::shared_ptr<T> shared_from_irelease(T* ptr) {
41  IE_SUPPRESS_DEPRECATED_START
42  std::shared_ptr<T> pointer(ptr, [](IRelease* p) {
43  if (p)
44  p->Release();
45  });
46  IE_SUPPRESS_DEPRECATED_END
47  return pointer;
48 }
49 
50 IE_SUPPRESS_DEPRECATED_END
51 
52 } // namespace details
53 } // namespace InferenceEngine
Definition: cldnn_config.hpp:16
The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS...
header file for no_copy class