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