OmniSciDB  2e3a973ef4
Parser::TrackedListPtr< T > Class Template Reference

#include <TrackedPtr.h>

Public Member Functions

 TrackedListPtr (const TrackedListPtr &)=delete
 
TrackedListPtroperator= (const TrackedListPtr &)=delete
 
std::list< T * > * release ()
 
void push_back (TrackedPtr< T > *item)
 
void push_back (T *item)
 

Static Public Member Functions

template<typename... Args>
static TrackedListPtr< T > * make (std::vector< std::unique_ptr< TrackedListPtr< T >>> &tracked_ptrs, Args &&... args)
 
static TrackedListPtr< T > * makeEmpty ()
 

Private Member Functions

 TrackedListPtr ()
 
 TrackedListPtr (size_t n)
 
 TrackedListPtr (size_t n, TrackedPtr< T > *val)
 
 TrackedListPtr (size_t n, T *val)
 

Private Attributes

std::unique_ptr< std::list< TrackedPtr< T > * > > value_
 
std::vector< std::unique_ptr< TrackedPtr< T > > > owned_ptrs_ {}
 
bool is_empty_
 
bool is_released_
 

Detailed Description

template<typename T>
class Parser::TrackedListPtr< T >

Class used to ensure ownership of dynamically allocated lists to string or Node objects that are dynamically allocated within the parser.

Template Parameters
T- std::string or Node type

Definition at line 115 of file TrackedPtr.h.

Constructor & Destructor Documentation

◆ TrackedListPtr() [1/5]

template<typename T >
Parser::TrackedListPtr< T >::TrackedListPtr ( const TrackedListPtr< T > &  )
delete

◆ TrackedListPtr() [2/5]

template<typename T >
Parser::TrackedListPtr< T >::TrackedListPtr ( )
inlineprivate

Definition at line 195 of file TrackedPtr.h.

195 : is_empty_(true), is_released_(false){};

◆ TrackedListPtr() [3/5]

template<typename T >
Parser::TrackedListPtr< T >::TrackedListPtr ( size_t  n)
inlineprivate

Definition at line 197 of file TrackedPtr.h.

198  : value_(std::make_unique<std::list<TrackedPtr<T>*>>(n))
199  , is_empty_(false)
200  , is_released_(false) {}
std::unique_ptr< std::list< TrackedPtr< T > * > > value_
Definition: TrackedPtr.h:190

◆ TrackedListPtr() [4/5]

template<typename T >
Parser::TrackedListPtr< T >::TrackedListPtr ( size_t  n,
TrackedPtr< T > *  val 
)
inlineprivate

Definition at line 202 of file TrackedPtr.h.

203  : value_(std::make_unique<std::list<TrackedPtr<T>*>>(n, val))
204  , is_empty_(false)
205  , is_released_(false) {}
std::unique_ptr< std::list< TrackedPtr< T > * > > value_
Definition: TrackedPtr.h:190

◆ TrackedListPtr() [5/5]

template<typename T >
Parser::TrackedListPtr< T >::TrackedListPtr ( size_t  n,
T *  val 
)
inlineprivate

Definition at line 207 of file TrackedPtr.h.

208  : value_(std::make_unique<std::list<TrackedPtr<T>*>>(
209  n,
210  TrackedPtr<T>::make(owned_ptrs_, (T*)val)))
211  , is_empty_(false)
212  , is_released_(false) {}
std::unique_ptr< std::list< TrackedPtr< T > * > > value_
Definition: TrackedPtr.h:190
static TrackedPtr< T > * make(std::vector< std::unique_ptr< TrackedPtr< T >>> &tracked_ptrs, Args &&... args)
Definition: TrackedPtr.h:70
std::vector< std::unique_ptr< TrackedPtr< T > > > owned_ptrs_
Definition: TrackedPtr.h:191

Member Function Documentation

◆ make()

template<typename T >
template<typename... Args>
static TrackedListPtr<T>* Parser::TrackedListPtr< T >::make ( std::vector< std::unique_ptr< TrackedListPtr< T >>> &  tracked_ptrs,
Args &&...  args 
)
inlinestatic

Creates an instance of a TrackedListPtr and returns a pointer to created instance.

Parameters
tracked_ptrs- TrackedListPtr unique pointer vector, which takes ownership of dynamically allocated objects.
args- Arguments to be used when creating contained string or Node pointer lists.
Returns
- pointer to created TrackedListPtr

Definition at line 170 of file TrackedPtr.h.

References run_benchmark_import::args.

172  {
173  std::unique_ptr<TrackedListPtr<T>> tracked_ptr{
174  new TrackedListPtr<T>(std::forward<Args>(args)...)};
175  const auto& ptr = tracked_ptrs.emplace_back(std::move(tracked_ptr));
176  return ptr.get();
177  }

◆ makeEmpty()

template<typename T >
static TrackedListPtr<T>* Parser::TrackedListPtr< T >::makeEmpty ( )
inlinestatic

Returns a pointer to a TrackedListPtr instance that represents an empty TrackedListPtr.

Definition at line 183 of file TrackedPtr.h.

183  {
184  static std::unique_ptr<TrackedListPtr<T>> empty_tracked_ptr_ =
185  std::unique_ptr<TrackedListPtr<T>>(new TrackedListPtr<T>());
186  return empty_tracked_ptr_.get();
187  }

◆ operator=()

template<typename T >
TrackedListPtr& Parser::TrackedListPtr< T >::operator= ( const TrackedListPtr< T > &  )
delete

◆ push_back() [1/2]

template<typename T >
void Parser::TrackedListPtr< T >::push_back ( TrackedPtr< T > *  item)
inline

Proxy method for adding a TrackedPtr object to the end of contained string or Node pointer list.

Parameters
item- TrackedPtr object to be added to list

Definition at line 147 of file TrackedPtr.h.

References Parser::TrackedPtr< T >::value_.

147 { value_->emplace_back(item); }
std::unique_ptr< std::list< TrackedPtr< T > * > > value_
Definition: TrackedPtr.h:190

◆ push_back() [2/2]

template<typename T >
void Parser::TrackedListPtr< T >::push_back ( T *  item)
inline

Proxy method for adding a string or Node pointer to the end of contained string or Node pointer list. This method accepts a string or Node pointer, which is wrapped in a TrackedPtr object that is then added to the list.

Parameters
item- string or Node pointer to be added to list

Definition at line 156 of file TrackedPtr.h.

References Parser::TrackedPtr< T >::value_.

156  {
157  value_->emplace_back(TrackedPtr<T>::make(owned_ptrs_, item));
158  }
std::unique_ptr< std::list< TrackedPtr< T > * > > value_
Definition: TrackedPtr.h:190
static TrackedPtr< T > * make(std::vector< std::unique_ptr< TrackedPtr< T >>> &tracked_ptrs, Args &&... args)
Definition: TrackedPtr.h:70
std::vector< std::unique_ptr< TrackedPtr< T > > > owned_ptrs_
Definition: TrackedPtr.h:191

◆ release()

template<typename T >
std::list<T*>* Parser::TrackedListPtr< T >::release ( )
inline

Releases ownership of contained string or Node pointer list and returns a pointer to the list.

Definition at line 127 of file TrackedPtr.h.

References CHECK, Parser::TrackedPtr< T >::is_empty_, Parser::TrackedPtr< T >::is_released_, run_benchmark_import::result, and Parser::TrackedPtr< T >::value_.

127  {
128  if (is_empty_) {
129  return nullptr;
130  }
132  is_released_ = true;
133 
134  auto result = new std::list<T*>();
135  for (auto& ptr : *value_) {
136  result->emplace_back(ptr->release());
137  }
138  return result;
139  }
std::unique_ptr< std::list< TrackedPtr< T > * > > value_
Definition: TrackedPtr.h:190
#define CHECK(condition)
Definition: Logger.h:197

Member Data Documentation

◆ is_empty_

template<typename T >
bool Parser::TrackedListPtr< T >::is_empty_
private

Definition at line 192 of file TrackedPtr.h.

◆ is_released_

template<typename T >
bool Parser::TrackedListPtr< T >::is_released_
private

Definition at line 193 of file TrackedPtr.h.

◆ owned_ptrs_

template<typename T >
std::vector<std::unique_ptr<TrackedPtr<T> > > Parser::TrackedListPtr< T >::owned_ptrs_ {}
private

Definition at line 191 of file TrackedPtr.h.

◆ value_

template<typename T >
std::unique_ptr<std::list<TrackedPtr<T>*> > Parser::TrackedListPtr< T >::value_
private

Definition at line 190 of file TrackedPtr.h.


The documentation for this class was generated from the following file: