mn_shared.hpp
Go to the documentation of this file.
1 
19 #ifndef MINLIB_ESP32_SHARED_OBJECT_
20 #define MINLIB_ESP32_SHARED_OBJECT_
21 
22 #include "mn_config.hpp"
23 
24 #include <stdint.h>
25 #include <string>
26 #include <esp_types.h>
27 
28 #include "mn_autolock.hpp"
29 
30 namespace mn {
35  template <class TOBJECT>
37  public:
38  using object_t = TOBJECT;
39  using ref_object_t = TOBJECT&;
40 
46  : m_refValue(refValue) { }
53 
54  return m_refValue;
55  }
60  void set_object (const ref_object_t refNewValue) {
62  m_refValue = refNewValue;
63  }
68  void operator = (const ref_object_t refNewValue) {
69  set_object(refNewValue);
70  }
75  operator object_t () const {
76  return get_object();
77  }
78 
79  protected:
88  };
89 
90 
91 
92  template <class TOBJECT>
94 
95 #if MN_THREAD_CONFIG_SHAREDOBJECT_PREUSING == MN_THREAD_CONFIG_YES
96 
105 
114 
123 
132 
141 
150 
161 
166  #ifdef _GLIBCXX_USE_WCHAR_T
168  using shared_wchar_t = basic_shared_object<wchar_t>;
170  using shared_wstring_t = basic_shared_object<std::wstring>;
171  #endif //_GLIBCXX_USE_WCHAR_T
172 
173  #if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99_STDINT_TR1))
175  using shared_char16_t = basic_shared_object<char16_t>;
177  using shared_char32_t = basic_shared_object<char32_t>;
178  #endif //((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99_STDINT_TR1))
179 
180 }
181 
182 #endif //MN_THREAD_CONFIG_SHAREDOBJECT_PREUSING == MN_THREAD_CONFIG_YES
183 
184 #endif //MINLIB_ESP32_SHARED_OBJECT_
Definition: mn_lock.hpp:122
Definition: mn_mutex.hpp:37
Definition: mn_shared.hpp:36
ref_object_t get_object() const
Definition: mn_shared.hpp:51
mutex_t m_pReadWriteLock
Definition: mn_shared.hpp:83
ref_object_t m_refValue
Definition: mn_shared.hpp:87
void operator=(const ref_object_t refNewValue)
Definition: mn_shared.hpp:68
TOBJECT object_t
Definition: mn_shared.hpp:38
basic_shared_object(const ref_object_t refValue)
Definition: mn_shared.hpp:45
TOBJECT & ref_object_t
Definition: mn_shared.hpp:39
void set_object(const ref_object_t refNewValue)
Definition: mn_shared.hpp:60
Definition: mn_allocator_typetraits.hpp:25
int lock(TLOCK &m1, unsigned int timeout)
Definition: mn_autolock.hpp:70