Code::Blocks  SVN r11506
classbrowserbuilderthread.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3  * http://www.gnu.org/licenses/gpl-3.0.html
4  */
5 
6 #ifndef CLASSBROWSERBUILDERTHREAD_H
7 #define CLASSBROWSERBUILDERTHREAD_H
8 
9 #include <wx/thread.h>
10 #include <wx/treectrl.h>
11 
12 #include "cctreectrl.h"
13 #include "nativeparser.h"
14 #include "parser/token.h"
15 #include "parser/parser.h"
16 
22 {
23 public:
26  {
30  };
31 
37 
40 
41  // Called from external:
42  void Init(NativeParser* np, CCTreeCtrl* treeTop, CCTreeCtrl* treeBottom,
43  const wxString& active_filename, void* user_data/*active project*/,
44  const BrowserOptions& bo, TokenTree* tt,
45  int idThreadEvent);
46 
47 
51  void ExpandItem(wxTreeItemId item);
52 #ifndef CC_NO_COLLAPSE_ITEM
53 
56  void CollapseItem(wxTreeItemId item);
57 #endif // CC_NO_COLLAPSE_ITEM
58 
59  // Called from external and SelectItemRequired():
60  void SelectItem(wxTreeItemId item);
61 
62  // Called from external:
63  void SelectItemRequired();
64 
68  void RequestTermination(bool terminate = true) { m_TerminationRequested = terminate; }
69 
70 protected:
71  virtual void* Entry();
72 
73  // Called from Entry():
74  void BuildTree();
75 
83  void RemoveInvalidNodes(CCTreeCtrl* tree, wxTreeItemId parent);
84 
89  void ExpandNamespaces(wxTreeItemId node, TokenKind tokenKind, int level);
90 
91  // Called from ExpandItem():
92  bool CreateSpecialFolders(CCTreeCtrl* tree, wxTreeItemId parent);
93 
94  // Called from CreateSpecialFolders():
96  const wxString& name, int imgIndex = -1, CCTreeCtrlData* data = 0);
97 
104  bool AddChildrenOf(CCTreeCtrl* tree, wxTreeItemId parent, int parentTokenIdx,
105  short int tokenKindMask = 0xffff, int tokenScopeMask = 0);
106  bool AddAncestorsOf(CCTreeCtrl* tree, wxTreeItemId parent, int tokenIdx);
107  bool AddDescendantsOf(CCTreeCtrl* tree, wxTreeItemId parent, int tokenIdx, bool allowInheritance = true);
108  // Called from ExpandItem(), SelectItem():
109  void AddMembersOf(CCTreeCtrl* tree, wxTreeItemId node);
110 
111 private:
112  // Called from AddChildrenOf(), AddAncestorsOf(), AddDescendantsOf():
113  bool AddNodes(CCTreeCtrl* tree, wxTreeItemId parent, const TokenIdxSet* tokens,
114  short int tokenKindMask = 0xffff, int tokenScopeMask = 0, bool allowGlobals = false);
115 
121  bool TokenMatchesFilter(const Token* token, bool locked = false);
122  // Called from AddNodes():
123  bool TokenContainsChildrenOfKind(const Token* token, int kind);
124 
125  // Called from BuildTree():
126  void SaveExpandedItems(CCTreeCtrl* tree, wxTreeItemId parent, int level);
127  void ExpandSavedItems(CCTreeCtrl* tree, wxTreeItemId parent, int level);
128  void SaveSelectedItem();
129  void SelectSavedItem();
130 
131 protected:
134 
143 
148 
150  void* m_UserData; // active project
153 
154  // pair of current-file-filter
162 
165 
168 
169 private:
173 
178 };
179 
180 #endif // CLASSBROWSERBUILDERTHREAD_H
void SaveExpandedItems(CCTreeCtrl *tree, wxTreeItemId parent, int level)
EThreadEvent
the builder threads&#39; event sent to the GUI(class browser window)
CCTreeCtrl * m_CCTreeCtrlBottom
pointer to the bottom wxTreeCtrl
void Init(NativeParser *np, CCTreeCtrl *treeTop, CCTreeCtrl *treeBottom, const wxString &active_filename, void *user_data, const BrowserOptions &bo, TokenTree *tt, int idThreadEvent)
std::deque< CCTreeCtrlExpandedItemData > ExpandedItemVect
Definition: cctreectrl.h:88
std::set< size_t, std::less< size_t > > TokenFileSet
Definition: token.h:19
virtual void * Entry()
a container class to hold all the Tokens getting from parsing stage
Definition: tokentree.h:37
worker thread to build the symbol browser tree controls(both the top tree and the bottom tree) When t...
void AddMembersOf(CCTreeCtrl *tree, wxTreeItemId node)
TokenIdxSet m_CurrentTokenSet
Tokens belong to the m_CurrentFileSet file set.
the thread is starting to (re)build the tree
virtual ~ClassBrowserBuilderThread()
destructor
TokenFileSet m_CurrentFileSet
A file set which contains a header file and the associated implementation file.
void RequestTermination(bool terminate=true)
ask the worker thread to die Called from external: when the class browser window get destroyed ...
void ExpandNamespaces(wxTreeItemId node, TokenKind tokenKind, int level)
recursively construct the children of node&#39;s children, which matches tokenKind Called from BuildTree(...
a symbol found in the parsed files, it can be many kinds, such as a variable, a class and so on...
Definition: token.h:82
std::set< int, std::less< int > > TokenIdxSet
Definition: token.h:16
bool TokenMatchesFilter(const Token *token, bool locked=false)
if the token should be shown in the tree, it will return true
ClassBrowserBuilderThread(wxEvtHandler *evtHandler, wxSemaphore &sem)
constructor
Options for the symbol browser, this specify how the symbol browser will shown.
Definition: parser_base.h:59
void ExpandSavedItems(CCTreeCtrl *tree, wxTreeItemId parent, int level)
bool AddNodes(CCTreeCtrl *tree, wxTreeItemId parent, const TokenIdxSet *tokens, short int tokenKindMask=0xffff, int tokenScopeMask=0, bool allowGlobals=false)
wxTreeItemId AddNodeIfNotThere(CCTreeCtrl *tree, wxTreeItemId parent, const wxString &name, int imgIndex=-1, CCTreeCtrlData *data=0)
bool AddAncestorsOf(CCTreeCtrl *tree, wxTreeItemId parent, int tokenIdx)
void CollapseItem(wxTreeItemId item)
remove the children of the tree item Called from external, BuildTree(), RemoveInvalidNodes(): ...
std::deque< CCTreeCtrlData > SelectedItemPath
Definition: cctreectrl.h:89
bool TokenContainsChildrenOfKind(const Token *token, int kind)
NativeParser class is just like a manager class to control Parser objects.
Definition: nativeparser.h:55
wxMutex m_ClassBrowserBuilderThreadMutex
Some member functions of ClassBrowserBuilderThread such as ExpandItem() can either be called from the...
Actual data stored with each node in the symbol tree.
Definition: cctreectrl.h:37
bool AddDescendantsOf(CCTreeCtrl *tree, wxTreeItemId parent, int tokenIdx, bool allowInheritance=true)
void RemoveInvalidNodes(CCTreeCtrl *tree, wxTreeItemId parent)
Remove any nodes no longer valid (due to update)
int idThreadEvent
the event ID which will be sent from worker thread to ClassBrowser
bool CreateSpecialFolders(CCTreeCtrl *tree, wxTreeItemId parent)
void ExpandItem(wxTreeItemId item)
construct the children of the tree item Called from external, BuildTree():
bool m_TerminationRequested
if this variable is true, the Entry() function should return
CCTreeCtrl * m_CCTreeCtrlTop
pointer to the top wxTreeCtrl
TokenKind
Definition: token.h:29
TokenIdxSet m_CurrentGlobalTokensSet
Special global scope tokens belong to the m_CurrentFileSet file set.
bool AddChildrenOf(CCTreeCtrl *tree, wxTreeItemId parent, int parentTokenIdx, short int tokenKindMask=0xffff, int tokenScopeMask=0)
Add the child nodes of the specified token.