Code::Blocks  SVN r11506
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
ClassBrowserBuilderThread Class Reference

worker thread to build the symbol browser tree controls(both the top tree and the bottom tree) When the thread is started, it is waiting for the semaphore, and once the GUI post the semaphore the builder will do the dirty job, once finished, it will wait again. More...

#include <classbrowserbuilderthread.h>

Inheritance diagram for ClassBrowserBuilderThread:
Collaboration diagram for ClassBrowserBuilderThread:

Public Types

enum  EThreadEvent { selectItemRequired, buildTreeStart, buildTreeEnd }
 the builder threads' event sent to the GUI(class browser window) More...
 
- Public Types inherited from wxThread
typedef void * ExitCode
 

Public Member Functions

 ClassBrowserBuilderThread (wxEvtHandler *evtHandler, wxSemaphore &sem)
 constructor More...
 
virtual ~ClassBrowserBuilderThread ()
 destructor More...
 
void Init (NativeParser *np, CCTreeCtrl *treeTop, CCTreeCtrl *treeBottom, const wxString &active_filename, void *user_data, const BrowserOptions &bo, TokenTree *tt, int idThreadEvent)
 
void ExpandItem (wxTreeItemId item)
 construct the children of the tree item Called from external, BuildTree(): More...
 
void CollapseItem (wxTreeItemId item)
 remove the children of the tree item Called from external, BuildTree(), RemoveInvalidNodes(): More...
 
void SelectItem (wxTreeItemId item)
 
void SelectItemRequired ()
 
void RequestTermination (bool terminate=true)
 ask the worker thread to die Called from external: when the class browser window get destroyed More...
 
- Public Member Functions inherited from wxThread
 wxThread (wxThreadKind kind=wxTHREAD_DETACHED)
 
virtual ~wxThread ()
 
wxThreadError Create (unsigned int stackSize=0)
 
wxThreadError Delete (ExitCode *rc=NULL, wxThreadWait waitMode=wxTHREAD_WAIT_BLOCK)
 
wxThreadIdType GetId () const
 
wxThreadKind GetKind () const
 
unsigned int GetPriority () const
 
bool IsAlive () const
 
bool IsDetached () const
 
bool IsPaused () const
 
bool IsRunning () const
 
wxThreadError Kill ()
 
wxThreadError Pause ()
 
wxThreadError Resume ()
 
wxThreadError Run ()
 
void SetPriority (unsigned int priority)
 
virtual bool TestDestroy ()
 
ExitCode Wait (wxThreadWait flags=wxTHREAD_WAIT_BLOCK)
 

Protected Member Functions

virtual void * Entry ()
 
void BuildTree ()
 
void RemoveInvalidNodes (CCTreeCtrl *tree, wxTreeItemId parent)
 Remove any nodes no longer valid (due to update) More...
 
void ExpandNamespaces (wxTreeItemId node, TokenKind tokenKind, int level)
 recursively construct the children of node's children, which matches tokenKind Called from BuildTree(): More...
 
bool CreateSpecialFolders (CCTreeCtrl *tree, wxTreeItemId parent)
 
wxTreeItemId AddNodeIfNotThere (CCTreeCtrl *tree, wxTreeItemId parent, const wxString &name, int imgIndex=-1, CCTreeCtrlData *data=0)
 
bool AddChildrenOf (CCTreeCtrl *tree, wxTreeItemId parent, int parentTokenIdx, short int tokenKindMask=0xffff, int tokenScopeMask=0)
 Add the child nodes of the specified token. More...
 
bool AddAncestorsOf (CCTreeCtrl *tree, wxTreeItemId parent, int tokenIdx)
 
bool AddDescendantsOf (CCTreeCtrl *tree, wxTreeItemId parent, int tokenIdx, bool allowInheritance=true)
 
void AddMembersOf (CCTreeCtrl *tree, wxTreeItemId node)
 
- Protected Member Functions inherited from wxThread
void Exit (ExitCode exitcode=0)
 

Protected Attributes

wxEvtHandlerm_Parent
 
wxSemaphorem_ClassBrowserSemaphore
 
wxMutex m_ClassBrowserBuilderThreadMutex
 Some member functions of ClassBrowserBuilderThread such as ExpandItem() can either be called from the main GUI thread(in ClassBrowser::OnTreeItemExpanding(wxTreeEvent& event)), or be called in the worker thread(in BuildTree() which is called in ClassBrowserBuilderThread::Entry()), to protect the member variables of the class(especially the wxTreeCtrl, we use the Mutex so that only one thread can access to those member variables. More...
 
NativeParserm_NativeParser
 
CCTreeCtrlm_CCTreeCtrlTop
 pointer to the top wxTreeCtrl More...
 
CCTreeCtrlm_CCTreeCtrlBottom
 pointer to the bottom wxTreeCtrl More...
 
wxString m_ActiveFilename
 
void * m_UserData
 
BrowserOptions m_BrowserOptions
 
TokenTreem_TokenTree
 
TokenFileSet m_CurrentFileSet
 A file set which contains a header file and the associated implementation file. More...
 
TokenIdxSet m_CurrentTokenSet
 Tokens belong to the m_CurrentFileSet file set. More...
 
TokenIdxSet m_CurrentGlobalTokensSet
 Special global scope tokens belong to the m_CurrentFileSet file set. More...
 

Private Member Functions

bool AddNodes (CCTreeCtrl *tree, wxTreeItemId parent, const TokenIdxSet *tokens, short int tokenKindMask=0xffff, int tokenScopeMask=0, bool allowGlobals=false)
 
bool TokenMatchesFilter (const Token *token, bool locked=false)
 if the token should be shown in the tree, it will return true More...
 
bool TokenContainsChildrenOfKind (const Token *token, int kind)
 
void SaveExpandedItems (CCTreeCtrl *tree, wxTreeItemId parent, int level)
 
void ExpandSavedItems (CCTreeCtrl *tree, wxTreeItemId parent, int level)
 
void SaveSelectedItem ()
 
void SelectSavedItem ()
 

Private Attributes

ExpandedItemVect m_ExpandedVect
 
SelectedItemPath m_SelectedPath
 
bool m_InitDone
 
bool m_TerminationRequested
 if this variable is true, the Entry() function should return More...
 
int m_idThreadEvent
 
wxTreeItemId m_SelectItemRequired
 

Additional Inherited Members

- Static Public Member Functions inherited from wxThread
static int GetCPUCount ()
 
static wxThreadIdType GetCurrentId ()
 
static wxThreadIdType GetMainId ()
 
static bool IsMain ()
 
static bool SetConcurrency (size_t level)
 
static void Sleep (unsigned long milliseconds)
 
static wxThreadThis ()
 
static void Yield ()
 

Detailed Description

worker thread to build the symbol browser tree controls(both the top tree and the bottom tree) When the thread is started, it is waiting for the semaphore, and once the GUI post the semaphore the builder will do the dirty job, once finished, it will wait again.

Definition at line 21 of file classbrowserbuilderthread.h.

Member Enumeration Documentation

◆ EThreadEvent

the builder threads' event sent to the GUI(class browser window)

Enumerator
selectItemRequired 
buildTreeStart 

an item is selected

buildTreeEnd 

the thread is starting to (re)build the tree

finishing (re)build the tree

Definition at line 25 of file classbrowserbuilderthread.h.

Constructor & Destructor Documentation

◆ ClassBrowserBuilderThread()

ClassBrowserBuilderThread::ClassBrowserBuilderThread ( wxEvtHandler evtHandler,
wxSemaphore sem 
)

constructor

Parameters
evtHandlerparent window notification events will sent to
sema semaphore reference which is used synchronize the GUI and the builder thread

Definition at line 66 of file classbrowserbuilderthread.cpp.

References wxID_NONE, and wxTHREAD_JOINABLE.

◆ ~ClassBrowserBuilderThread()

ClassBrowserBuilderThread::~ClassBrowserBuilderThread ( )
virtual

destructor

Definition at line 84 of file classbrowserbuilderthread.cpp.

Member Function Documentation

◆ AddAncestorsOf()

bool ClassBrowserBuilderThread::AddAncestorsOf ( CCTreeCtrl tree,
wxTreeItemId  parent,
int  tokenIdx 
)
protected

◆ AddChildrenOf()

bool ClassBrowserBuilderThread::AddChildrenOf ( CCTreeCtrl tree,
wxTreeItemId  parent,
int  parentTokenIdx,
short int  tokenKindMask = 0xffff,
int  tokenScopeMask = 0 
)
protected

Add the child nodes of the specified token.

Parameters
treethe symbol tree control
parentthe specified node
parentTokenIdxthe Token index associated with the node Called from ExpandItem()

Definition at line 795 of file classbrowserbuilderthread.cpp.

References _T, AddNodes(), TokenTree::at(), bdfEverything, bdfWorkspace, CBBT_SANITY_CHECK, CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, BrowserOptions::displayFilter, TokenTree::GetGlobalNameSpaces(), m_BrowserOptions, Token::m_Children, m_CurrentGlobalTokensSet, m_TokenTree, s_TokenTreeMutex, and TRACE.

Referenced by AddMembersOf(), ExpandItem(), and RequestTermination().

◆ AddDescendantsOf()

bool ClassBrowserBuilderThread::AddDescendantsOf ( CCTreeCtrl tree,
wxTreeItemId  parent,
int  tokenIdx,
bool  allowInheritance = true 
)
protected

◆ AddMembersOf()

void ClassBrowserBuilderThread::AddMembersOf ( CCTreeCtrl tree,
wxTreeItemId  node 
)
protected

◆ AddNodeIfNotThere()

wxTreeItemId ClassBrowserBuilderThread::AddNodeIfNotThere ( CCTreeCtrl tree,
wxTreeItemId  parent,
const wxString name,
int  imgIndex = -1,
CCTreeCtrlData data = 0 
)
protected

◆ AddNodes()

bool ClassBrowserBuilderThread::AddNodes ( CCTreeCtrl tree,
wxTreeItemId  parent,
const TokenIdxSet tokens,
short int  tokenKindMask = 0xffff,
int  tokenScopeMask = 0,
bool  allowGlobals = false 
)
private

◆ BuildTree()

void ClassBrowserBuilderThread::BuildTree ( )
protected

◆ CollapseItem()

void ClassBrowserBuilderThread::CollapseItem ( wxTreeItemId  item)

◆ CreateSpecialFolders()

bool ClassBrowserBuilderThread::CreateSpecialFolders ( CCTreeCtrl tree,
wxTreeItemId  parent 
)
protected

◆ Entry()

void * ClassBrowserBuilderThread::Entry ( )
protectedvirtual

◆ ExpandItem()

void ClassBrowserBuilderThread::ExpandItem ( wxTreeItemId  item)

◆ ExpandNamespaces()

void ClassBrowserBuilderThread::ExpandNamespaces ( wxTreeItemId  node,
TokenKind  tokenKind,
int  level 
)
protected

recursively construct the children of node's children, which matches tokenKind Called from BuildTree():

Parameters
levelthe recursive level

Definition at line 663 of file classbrowserbuilderthread.cpp.

References _T, CBBT_SANITY_CHECK, wxTreeCtrl::Expand(), BrowserOptions::expandNS, F(), wxTreeCtrl::GetFirstChild(), wxTreeCtrl::GetItemData(), wxTreeCtrl::GetNextSibling(), wxTreeItemId::IsOk(), m_BrowserOptions, m_CCTreeCtrlTop, Token::m_Name, CCTreeCtrlData::m_Token, Token::m_TokenKind, and TRACE.

Referenced by BuildTree(), and RequestTermination().

◆ ExpandSavedItems()

void ClassBrowserBuilderThread::ExpandSavedItems ( CCTreeCtrl tree,
wxTreeItemId  parent,
int  level 
)
private

◆ Init()

void ClassBrowserBuilderThread::Init ( NativeParser np,
CCTreeCtrl treeTop,
CCTreeCtrl treeBottom,
const wxString active_filename,
void *  user_data,
const BrowserOptions bo,
TokenTree tt,
int  idThreadEvent 
)

◆ RemoveInvalidNodes()

void ClassBrowserBuilderThread::RemoveInvalidNodes ( CCTreeCtrl tree,
wxTreeItemId  parent 
)
protected

◆ RequestTermination()

void ClassBrowserBuilderThread::RequestTermination ( bool  terminate = true)
inline

◆ SaveExpandedItems()

void ClassBrowserBuilderThread::SaveExpandedItems ( CCTreeCtrl tree,
wxTreeItemId  parent,
int  level 
)
private

◆ SaveSelectedItem()

void ClassBrowserBuilderThread::SaveSelectedItem ( )
private

◆ SelectItem()

void ClassBrowserBuilderThread::SelectItem ( wxTreeItemId  item)

◆ SelectItemRequired()

void ClassBrowserBuilderThread::SelectItemRequired ( )

◆ SelectSavedItem()

void ClassBrowserBuilderThread::SelectSavedItem ( )
private

◆ TokenContainsChildrenOfKind()

bool ClassBrowserBuilderThread::TokenContainsChildrenOfKind ( const Token token,
int  kind 
)
private

◆ TokenMatchesFilter()

bool ClassBrowserBuilderThread::TokenMatchesFilter ( const Token token,
bool  locked = false 
)
private

if the token should be shown in the tree, it will return true

The view option of the symbol browser determines which tokens should be shown in the tree Called from RemoveInvalidNodes(), AddNodes(), CreateSpecialFolder()

Definition at line 1104 of file classbrowserbuilderthread.cpp.

References _T, TokenTree::at(), bdfEverything, bdfFile, bdfProject, bdfWorkspace, CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, BrowserOptions::displayFilter, m_BrowserOptions, Token::m_Children, m_CurrentTokenSet, Token::m_Index, Token::m_IsLocal, Token::m_IsTemp, m_TokenTree, m_UserData, Token::m_UserData, s_TokenTreeMutex, and TRACE.

Referenced by AddNodes(), CreateSpecialFolders(), RemoveInvalidNodes(), and RequestTermination().

Member Data Documentation

◆ m_ActiveFilename

wxString ClassBrowserBuilderThread::m_ActiveFilename
protected

Definition at line 149 of file classbrowserbuilderthread.h.

Referenced by ExpandItem(), Init(), and SelectItem().

◆ m_BrowserOptions

BrowserOptions ClassBrowserBuilderThread::m_BrowserOptions
protected

◆ m_CCTreeCtrlBottom

CCTreeCtrl* ClassBrowserBuilderThread::m_CCTreeCtrlBottom
protected

pointer to the bottom wxTreeCtrl

Definition at line 147 of file classbrowserbuilderthread.h.

Referenced by AddMembersOf(), BuildTree(), Entry(), Init(), RemoveInvalidNodes(), and SelectItem().

◆ m_CCTreeCtrlTop

CCTreeCtrl* ClassBrowserBuilderThread::m_CCTreeCtrlTop
protected

◆ m_ClassBrowserBuilderThreadMutex

wxMutex ClassBrowserBuilderThread::m_ClassBrowserBuilderThreadMutex
protected

Some member functions of ClassBrowserBuilderThread such as ExpandItem() can either be called from the main GUI thread(in ClassBrowser::OnTreeItemExpanding(wxTreeEvent& event)), or be called in the worker thread(in BuildTree() which is called in ClassBrowserBuilderThread::Entry()), to protect the member variables of the class(especially the wxTreeCtrl, we use the Mutex so that only one thread can access to those member variables.

Definition at line 141 of file classbrowserbuilderthread.h.

Referenced by CollapseItem(), ExpandItem(), Init(), and SelectItem().

◆ m_ClassBrowserSemaphore

wxSemaphore& ClassBrowserBuilderThread::m_ClassBrowserSemaphore
protected

Definition at line 133 of file classbrowserbuilderthread.h.

Referenced by Entry().

◆ m_CurrentFileSet

TokenFileSet ClassBrowserBuilderThread::m_CurrentFileSet
protected

A file set which contains a header file and the associated implementation file.

If the view option "Current file's symbols" is selected, the symbol tree will show tokens from those files, e.g. if the a.cpp shown in the current active editor, then m_CurrentFileSet maybe contains two files: a.cpp and a.h

Definition at line 161 of file classbrowserbuilderthread.h.

Referenced by Init().

◆ m_CurrentGlobalTokensSet

TokenIdxSet ClassBrowserBuilderThread::m_CurrentGlobalTokensSet
protected

Special global scope tokens belong to the m_CurrentFileSet file set.

Definition at line 167 of file classbrowserbuilderthread.h.

Referenced by AddChildrenOf(), and Init().

◆ m_CurrentTokenSet

TokenIdxSet ClassBrowserBuilderThread::m_CurrentTokenSet
protected

Tokens belong to the m_CurrentFileSet file set.

Definition at line 164 of file classbrowserbuilderthread.h.

Referenced by Init(), and TokenMatchesFilter().

◆ m_ExpandedVect

ExpandedItemVect ClassBrowserBuilderThread::m_ExpandedVect
private

Definition at line 170 of file classbrowserbuilderthread.h.

Referenced by BuildTree(), ExpandSavedItems(), and SaveExpandedItems().

◆ m_idThreadEvent

int ClassBrowserBuilderThread::m_idThreadEvent
private

Definition at line 176 of file classbrowserbuilderthread.h.

Referenced by BuildTree(), Init(), and SelectSavedItem().

◆ m_InitDone

bool ClassBrowserBuilderThread::m_InitDone
private

Definition at line 172 of file classbrowserbuilderthread.h.

Referenced by BuildTree(), CollapseItem(), and ExpandItem().

◆ m_NativeParser

NativeParser* ClassBrowserBuilderThread::m_NativeParser
protected

◆ m_Parent

wxEvtHandler* ClassBrowserBuilderThread::m_Parent
protected

Definition at line 132 of file classbrowserbuilderthread.h.

Referenced by BuildTree(), and SelectSavedItem().

◆ m_SelectedPath

SelectedItemPath ClassBrowserBuilderThread::m_SelectedPath
private

Definition at line 171 of file classbrowserbuilderthread.h.

Referenced by SaveSelectedItem(), and SelectSavedItem().

◆ m_SelectItemRequired

wxTreeItemId ClassBrowserBuilderThread::m_SelectItemRequired
private

Definition at line 177 of file classbrowserbuilderthread.h.

Referenced by SelectItemRequired(), and SelectSavedItem().

◆ m_TerminationRequested

bool ClassBrowserBuilderThread::m_TerminationRequested
private

if this variable is true, the Entry() function should return

Definition at line 175 of file classbrowserbuilderthread.h.

Referenced by Entry(), and RequestTermination().

◆ m_TokenTree

TokenTree* ClassBrowserBuilderThread::m_TokenTree
protected

◆ m_UserData

void* ClassBrowserBuilderThread::m_UserData
protected

Definition at line 150 of file classbrowserbuilderthread.h.

Referenced by Init(), and TokenMatchesFilter().


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