Static Value-Flow Analysis
Public Member Functions | Private Attributes | List of all members
SVF::WriterPtrPool< T > Class Template Reference

Bookkeeping class to keep track of the IDs of objects that doesn't have any ID. E.g., SVFValue, XXXEdge. More...

#include <SVFFileSystem.h>

Public Member Functions

size_t getID (const T *ptr)
 
void saveID (const T *ptr)
 
const T * getPtr (size_t id) const
 
const std::vector< const T * > & getPool () const
 
size_t size () const
 
void reserve (size_t size)
 
auto begin () const
 
auto end () const
 

Private Attributes

Map< const T *, size_t > ptrToId
 
std::vector< const T * > ptrPool
 

Detailed Description

template<typename T>
class SVF::WriterPtrPool< T >

Bookkeeping class to keep track of the IDs of objects that doesn't have any ID. E.g., SVFValue, XXXEdge.

Template Parameters
T

Definition at line 232 of file SVFFileSystem.h.

Member Function Documentation

◆ begin()

template<typename T >
auto SVF::WriterPtrPool< T >::begin ( ) const
inline

Definition at line 278 of file SVFFileSystem.h.

279  {
280  return ptrPool.cbegin();
281  }
std::vector< const T * > ptrPool

◆ end()

template<typename T >
auto SVF::WriterPtrPool< T >::end ( ) const
inline

Definition at line 283 of file SVFFileSystem.h.

284  {
285  return ptrPool.cend();
286  }

◆ getID()

template<typename T >
size_t SVF::WriterPtrPool< T >::getID ( const T *  ptr)
inline

Definition at line 239 of file SVFFileSystem.h.

240  {
241  if (!ptr)
242  return 0;
243 
244  typename decltype(ptrToId)::iterator it;
245  bool inserted;
246  std::tie(it, inserted) = ptrToId.emplace(ptr, 1 + ptrPool.size());
247  if (inserted)
248  ptrPool.push_back(ptr);
249  return it->second;
250  }
Map< const T *, size_t > ptrToId

◆ getPool()

template<typename T >
const std::vector<const T*>& SVF::WriterPtrPool< T >::getPool ( ) const
inline

Definition at line 263 of file SVFFileSystem.h.

264  {
265  return ptrPool;
266  }

◆ getPtr()

template<typename T >
const T* SVF::WriterPtrPool< T >::getPtr ( size_t  id) const
inline

Definition at line 257 of file SVFFileSystem.h.

258  {
259  assert(id <= ptrPool.size() && "Invalid ID");
260  return id ? ptrPool[id - 1] : nullptr;
261  }

◆ reserve()

template<typename T >
void SVF::WriterPtrPool< T >::reserve ( size_t  size)
inline

Definition at line 273 of file SVFFileSystem.h.

274  {
275  ptrPool.reserve(size);
276  }
size_t size() const

◆ saveID()

template<typename T >
void SVF::WriterPtrPool< T >::saveID ( const T *  ptr)
inline

Definition at line 252 of file SVFFileSystem.h.

253  {
254  getID(ptr);
255  }
size_t getID(const T *ptr)

◆ size()

template<typename T >
size_t SVF::WriterPtrPool< T >::size ( ) const
inline

Definition at line 268 of file SVFFileSystem.h.

269  {
270  return ptrPool.size();
271  }

Member Data Documentation

◆ ptrPool

template<typename T >
std::vector<const T*> SVF::WriterPtrPool< T >::ptrPool
private

Definition at line 236 of file SVFFileSystem.h.

◆ ptrToId

template<typename T >
Map<const T*, size_t> SVF::WriterPtrPool< T >::ptrToId
private

Definition at line 235 of file SVFFileSystem.h.


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