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  * @brief A header file that provides wrapper classes for IVariableState
7  *
8  * @file ie_memory_state.hpp
9  */
10 
11 #pragma once
12 
13 #include <string>
14 
15 #include "ie_imemory_state.hpp"
17 #include "details/ie_so_loader.h"
18 
19 namespace InferenceEngine {
20 
21 /**
22  * @brief C++ exception based error reporting wrapper of API class IVariableState
23  */
25  IVariableState::Ptr actual = nullptr;
26  details::SharedObjectLoader::Ptr plugin = {};
27 
28 public:
29  /**
30  * @brief constructs VariableState from the initialized shared_pointer
31  * @param pState Initialized shared pointer
32  * @param plg Optional: Plugin to use. This is required to ensure that VariableState can work properly even if plugin object is destroyed.
33  */
34  explicit VariableState(IVariableState::Ptr pState, details::SharedObjectLoader::Ptr plg = {}) : actual(pState), plugin(plg) {
35  if (actual == nullptr) {
36  THROW_IE_EXCEPTION << "VariableState wrapper was not initialized.";
37  }
38  }
39 
40  /**
41  * @copybrief IVariableState::Reset
42  *
43  * Wraps IVariableState::Reset
44  */
45  void Reset() {
46  CALL_STATUS_FNC_NO_ARGS(Reset);
47  }
48 
49  /**
50  * @copybrief IVariableState::GetName
51  *
52  * Wraps IVariableState::GetName
53  * @return A string representing a state name
54  */
55  std::string GetName() const {
56  char name[256];
57  CALL_STATUS_FNC(GetName, name, sizeof(name));
58  return name;
59  }
60 
61  /**
62  * @copybrief IVariableState::GetState
63  *
64  * Wraps IVariableState::GetState
65  * @return A blob representing a state
66  */
67  Blob::CPtr GetState() const {
68  Blob::CPtr stateBlob;
69  CALL_STATUS_FNC(GetState, stateBlob);
70  return stateBlob;
71  }
72 
73  /**
74  * @copybrief IVariableState::GetLastState
75  * @deprecated Use IVariableState::SetState instead
76  *
77  * Wraps IVariableState::GetLastState
78  * @return A blob representing a last state
79  */
80  INFERENCE_ENGINE_DEPRECATED("Use VariableState::GetState function instead")
81  Blob::CPtr GetLastState() const {
82  return GetState();
83  }
84 
85  /**
86  * @copybrief IVariableState::SetState
87  *
88  * Wraps IVariableState::SetState
89  * @param state The current state to set
90  */
91  void SetState(Blob::Ptr state) {
92  CALL_STATUS_FNC(SetState, state);
93  }
94 };
95 
96 /**
97  * @brief For compatibility reasons.
98  */
100 
101 } // namespace InferenceEngine
This class represents a universal container in the Inference Engine.
Definition: ie_blob.h:38
std::shared_ptr< const Blob > CPtr
A smart pointer to the const Blob object.
Definition: ie_blob.h:48
std::shared_ptr< Blob > Ptr
A smart pointer containing Blob object.
Definition: ie_blob.h:43
std::shared_ptr< IVariableState > Ptr
A shared pointer to the IVariableState interface.
Definition: ie_imemory_state.hpp:30
C++ exception based error reporting wrapper of API class IVariableState.
Definition: ie_memory_state.hpp:24
Blob::CPtr GetState() const
Returns the value of the variable state.
Definition: ie_memory_state.hpp:67
VariableState(IVariableState::Ptr pState, details::SharedObjectLoader::Ptr plg={})
constructs VariableState from the initialized shared_pointer
Definition: ie_memory_state.hpp:34
std::string GetName() const
Gets name of current variable state, if length of array is not enough name is truncated by len,...
Definition: ie_memory_state.hpp:55
void SetState(Blob::Ptr state)
Sets the new state for the next inference.
Definition: ie_memory_state.hpp:91
void Reset()
Reset internal variable state for relevant infer request, to a value specified as default for accordi...
Definition: ie_memory_state.hpp:45
Blob::CPtr GetLastState() const
Returns the value of the variable state.
Definition: ie_memory_state.hpp:81
#define THROW_IE_EXCEPTION
A macro used to throw the exception with a notable description.
Definition: ie_exception.hpp:25
A header file that provides macros to handle no exception methods.
a header file for IVariableState interface
A header file for definition of abstraction over platform specific shared objects.