Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
ImPool< T > Struct Template Reference

#include <src/imgui/imgui_internal.h>

+ Inheritance diagram for ImPool< T >:
+ Collaboration diagram for ImPool< T >:

Public Member Functions

 ImPool ()
 
 ~ImPool ()
 
T * GetByKey (ImGuiID key)
 
T * GetByIndex (ImPoolIdx n)
 
ImPoolIdx GetIndex (const T *p) const
 
T * GetOrAddByKey (ImGuiID key)
 
bool Contains (const T *p) const
 
void Clear ()
 
T * Add ()
 
void Remove (ImGuiID key, const T *p)
 
void Remove (ImGuiID key, ImPoolIdx idx)
 
void Reserve (int capacity)
 
int GetSize () const
 

Public Attributes

ImVector< T > Buf
 
ImGuiStorage Map
 
ImPoolIdx FreeIdx
 

Detailed Description

template<typename T>
struct ImPool< T >

Constructor & Destructor Documentation

◆ ImPool()

template<typename T >
ImPool< T >::ImPool ( )
inline
613{ FreeIdx = 0; }
ImPoolIdx FreeIdx
Definition imgui_internal.h:611

◆ ~ImPool()

template<typename T >
ImPool< T >::~ImPool ( )
inline
614{ Clear(); }
void Clear()
Definition imgui_internal.h:620

Member Function Documentation

◆ Add()

template<typename T >
T * ImPool< T >::Add ( )
inline
621{ int idx = FreeIdx; if (idx == Buf.Size) { Buf.resize(Buf.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Buf[idx]; } IM_PLACEMENT_NEW(&Buf[idx]) T(); return &Buf[idx]; }
#define IM_PLACEMENT_NEW(_PTR)
Definition imgui.h:1636
ImVector< T > Buf
Definition imgui_internal.h:609

References IM_PLACEMENT_NEW, ImVector< T >::resize(), and ImVector< T >::Size.

+ Here is the call graph for this function:

◆ Clear()

template<typename T >
void ImPool< T >::Clear ( )
inline
620{ for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Buf[idx].~T(); } Map.Clear(); Buf.clear(); FreeIdx = 0; }
ImVector< ImGuiStoragePair > Data
Definition imgui.h:2089
void Clear()
Definition imgui.h:2094
ImGuiStorage Map
Definition imgui_internal.h:610

References ImVector< T >::clear(), ImGuiStorage::Clear(), and ImGuiStorage::Data.

Referenced by ImGui::Shutdown().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Contains()

template<typename T >
bool ImPool< T >::Contains ( const T *  p) const
inline
619{ return (p >= Buf.Data && p < Buf.Data + Buf.Size); }

References ImVector< T >::Data, and ImVector< T >::Size.

Referenced by GetTabBarRefFromTabBar().

+ Here is the caller graph for this function:

◆ GetByIndex()

template<typename T >
T * ImPool< T >::GetByIndex ( ImPoolIdx  n)
inline
616{ return &Buf[n]; }

Referenced by ImGui::EndTable(), GetTabBarFromTabBarRef(), ImGui::NewFrame(), SetCurrentWindow(), ImGui::ShowMetricsWindow(), TableSettingsHandler_ApplyAll(), and TableSettingsHandler_ClearAll().

+ Here is the caller graph for this function:

◆ GetByKey()

template<typename T >
T * ImPool< T >::GetByKey ( ImGuiID  key)
inline
615{ int idx = Map.GetInt(key, -1); return (idx != -1) ? &Buf[idx] : NULL; }
IMGUI_API int GetInt(ImGuiID key, int default_val=0) const
Definition imgui.cpp:1915

References ImGuiStorage::GetInt().

Referenced by ImGui::TableFindByID().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetIndex()

template<typename T >
ImPoolIdx ImPool< T >::GetIndex ( const T *  p) const
inline
617{ IM_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size); return (ImPoolIdx)(p - Buf.Data); }
#define IM_ASSERT(_EXPR)
Definition imgui.h:81
int ImPoolIdx
Definition imgui_internal.h:605

References ImVector< T >::Data, IM_ASSERT, and ImVector< T >::Size.

Referenced by ImGui::BeginTableEx(), ImGui::EndTable(), GetTabBarRefFromTabBar(), ImGui::TableGcCompactTransientBuffers(), and ImGui::TableRemove().

+ Here is the caller graph for this function:

◆ GetOrAddByKey()

template<typename T >
T * ImPool< T >::GetOrAddByKey ( ImGuiID  key)
inline
618{ int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Buf[*p_idx]; *p_idx = FreeIdx; return Add(); }
IMGUI_API int * GetIntRef(ImGuiID key, int default_val=0)
Definition imgui.cpp:1945
T * Add()
Definition imgui_internal.h:621

References ImGuiStorage::GetIntRef().

Referenced by ImGui::BeginTabBar(), and ImGui::BeginTableEx().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSize()

template<typename T >
int ImPool< T >::GetSize ( ) const
inline
625{ return Buf.Size; }

References ImVector< T >::Size.

Referenced by ImGui::ShowMetricsWindow(), TableSettingsHandler_ApplyAll(), and TableSettingsHandler_ClearAll().

+ Here is the caller graph for this function:

◆ Remove() [1/2]

template<typename T >
void ImPool< T >::Remove ( ImGuiID  key,
const T *  p 
)
inline
622{ Remove(key, GetIndex(p)); }
ImPoolIdx GetIndex(const T *p) const
Definition imgui_internal.h:617
void Remove(ImGuiID key, const T *p)
Definition imgui_internal.h:622

References ImPool< T >::Remove().

Referenced by ImPool< T >::Remove(), and ImGui::TableRemove().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Remove() [2/2]

template<typename T >
void ImPool< T >::Remove ( ImGuiID  key,
ImPoolIdx  idx 
)
inline
623{ Buf[idx].~T(); *(int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
IMGUI_API void SetInt(ImGuiID key, int val)
Definition imgui.cpp:1975

References ImGuiStorage::SetInt().

+ Here is the call graph for this function:

◆ Reserve()

template<typename T >
void ImPool< T >::Reserve ( int  capacity)
inline
624{ Buf.reserve(capacity); Map.Data.reserve(capacity); }

References ImGuiStorage::Data, and ImVector< T >::reserve().

+ Here is the call graph for this function:

Member Data Documentation

◆ Buf

template<typename T >
ImVector<T> ImPool< T >::Buf

◆ FreeIdx

template<typename T >
ImPoolIdx ImPool< T >::FreeIdx

◆ Map

template<typename T >
ImGuiStorage ImPool< T >::Map

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