EventAnalysis  1.0.0
ObjPtr.h
Go to the documentation of this file.
1 /*
2  * ObjPtr.h
3  *
4  * Created on: 16 Aug 2017
5  * Author: Nicola Mori
6  */
7 
10 #ifndef OBJPTR_H_
11 #define OBJPTR_H_
12 
13 #include "core/ObserverPtr.h"
14 #include "core/RetrievalResult.h"
15 
16 namespace EA {
17 
31 template <typename T> class ObjPtr : public observer_ptr<T> {
32 public:
39 
44  ObjPtr(const ObjPtr<T> &objPtr) : observer_ptr<T>(objPtr), _result(objPtr._result) {}
45 
50  ObjPtr(const ObjPtr<T> &&objPtr) : observer_ptr<T>(std::move(objPtr)), _result(std::move(objPtr._result)) {}
51 
56  ObjPtr(std::nullptr_t) : observer_ptr<T>(nullptr), _result(RetrievalResult::NOTFOUND) {}
57 
63  ObjPtr &operator=(const ObjPtr &rhs) {
65  _result = rhs._result;
66  return *this;
67  }
68 
74  ObjPtr &operator=(std::nullptr_t) {
77  return *this;
78  }
79 
85  ObjPtr &operator=(const ObjPtr &&rhs) {
86  observer_ptr<T>::operator=(std::move(rhs));
87  _result = std::move(rhs._result);
88  return *this;
89  }
90 
96 
97 private:
98  friend class ObjectMap;
99  friend class DataStore;
100  friend class EventDataStore;
101 
103 
112  ObjPtr(const observer_ptr<T> &&obsPtr) : observer_ptr<T>(std::move(obsPtr)), _result(RetrievalResult::NOTFOUND) {}
113 
115 };
116 
117 } // namespace EA
118 
119 #endif /* OBJPTR_H_ */
Class describing a pointer to an object retrieved from an ObjectMap.
Definition: ObjPtr.h:31
A smart pointer not owning the wrapped object.
Definition: ObserverPtr.h:28
RetrievalResult
Definition: RetrievalResult.h:16
observer_ptr & operator=(const observer_ptr< W > &p)
Assignment operator.
Definition: ObserverPtr.h:57
ObjPtr(std::nullptr_t)
Constructor from nullptr.
Definition: ObjPtr.h:56
ObjPtr(const observer_ptr< T > &&obsPtr)
Allow friend classes to set the observer_ptr.
Definition: ObjPtr.h:112
IncludeFileExc.h IncludeFileExc class declaration.
Definition: Algorithm.h:21
ObjPtr & operator=(const ObjPtr &&rhs)
Move assignment operator.
Definition: ObjPtr.h:85
ObjPtr(const ObjPtr< T > &objPtr)
Copy constructor.
Definition: ObjPtr.h:44
A map between strings and objects of ObjectWrapper kind.
Definition: ObjectMap.h:32
ObjPtr & operator=(const ObjPtr &rhs)
Assignment operator.
Definition: ObjPtr.h:63
ObjPtr()
Default constructor.
Definition: ObjPtr.h:38
ObjPtr(const ObjPtr< T > &&objPtr)
Move constructor.
Definition: ObjPtr.h:50
Definition: DataStore.h:357
RetrievalResult GetRetrievalResult()
Getter for the result of the retrieve operation that generated this object.
Definition: ObjPtr.h:95
Object found but class does not match with requested.
Data store class.
Definition: DataStore.h:41
RetrievalResult _result
Definition: ObjPtr.h:114
ObjPtr & operator=(std::nullptr_t)
Assignment operator from nullptr.
Definition: ObjPtr.h:74