ie_memory_state.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  * @file
7  */
8 
9 #pragma once
10 
11 #include <string>
12 #include <ie_imemory_state.hpp>
13 
14 namespace InferenceEngine {
15 
16 /**
17  * @brief C++ exception based error reporting wrapper of API class IMemoryState
18  */
19 class MemoryState {
20  IMemoryState::Ptr actual = nullptr;
21 
22 public:
23  /**
24  * constructs MemoryState from the initialized shared_pointer
25  * @param pState Initialized shared pointer
26  */
27  explicit MemoryState(IMemoryState::Ptr pState): actual(pState) {
28  if (actual == nullptr) {
29  THROW_IE_EXCEPTION << "MemoryState wrapper was not initialized.";
30  }
31  }
32 
33  /**
34  * @copybrief IMemoryState::Reset
35  *
36  * Wraps IMemoryState::Reset
37  */
38  void Reset() {
39  CALL_STATUS_FNC_NO_ARGS(Reset);
40  }
41 
42  /**
43  * @copybrief IMemoryState::GetName
44  *
45  * Wraps IMemoryState::GetName
46  * @return A string representing a state name
47  */
48  std::string GetName() const {
49  char name[256];
50  CALL_STATUS_FNC(GetName, name, sizeof(name));
51  return name;
52  }
53 
54  /**
55  * @copybrief IMemoryState::GetLastState
56  *
57  * Wraps IMemoryState::GetLastState
58  * @return A blob representing a last state
59  */
61  Blob::CPtr stateBlob;
62  CALL_STATUS_FNC(GetLastState, stateBlob);
63  return stateBlob;
64  }
65 
66  /**
67  * @copybrief IMemoryState::SetState
68  *
69  * Wraps IMemoryState::SetState
70  * @param state The current state to set
71  */
72  void SetState(Blob::Ptr state) {
73  CALL_STATUS_FNC(SetState, state);
74  }
75 };
76 
77 } // namespace InferenceEngine
#define THROW_IE_EXCEPTION
A macro used to throw the exception with a notable description.
Definition: ie_exception.hpp:25
Definition: cldnn_config.hpp:16
void SetState(Blob::Ptr state)
Definition: ie_memory_state.hpp:72
std::string GetName() const
Definition: ie_memory_state.hpp:48
a header file for IMemoryState interface
std::shared_ptr< IMemoryState > Ptr
A shared pointer to the IMemoryState interface.
Definition: ie_imemory_state.hpp:29
std::string name
Layer name.
Definition: ie_layers.h:42
std::shared_ptr< const Blob > CPtr
A smart pointer to the const Blob object.
Definition: ie_blob.h:47
std::shared_ptr< Blob > Ptr
A smart pointer containing Blob object.
Definition: ie_blob.h:42
Blob::CPtr GetLastState() const
Definition: ie_memory_state.hpp:60
C++ exception based error reporting wrapper of API class IMemoryState.
Definition: ie_memory_state.hpp:19
MemoryState(IMemoryState::Ptr pState)
Definition: ie_memory_state.hpp:27
void Reset()
Definition: ie_memory_state.hpp:38