NCBI C++ ToolKit
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
CTreeQueryExec Class Reference

Search Toolkit Book for CTreeQueryExec

class CTreeQueryExec More...

#include <gui/widgets/phylo_tree/phylo_tree_query_exec.hpp>

+ Inheritance diagram for CTreeQueryExec:
+ Collaboration diagram for CTreeQueryExec:

Classes

struct  PhyloTreePointer
 for iterating through the node tree without recursion More...
 

Public Types

typedef CPhyloTree TTreeType
 
typedef CPhyloTree::TTreeIdx TTreeIdx
 
typedef CPhyloTree::TNodeType TNodeType
 
- Public Types inherited from CQueryExec
typedef unsigned int TFieldID
 
- Public Types inherited from CObject
enum  EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern }
 Control filling of newly allocated memory. More...
 
typedef CObjectCounterLocker TLockerType
 Default locker type for CRef. More...
 
typedef atomic< Uint8TCounter
 Counter type is CAtomiCounter. More...
 
typedef Uint8 TCount
 Alias for value type of counter. More...
 

Public Member Functions

 CTreeQueryExec (const CBioTreeFeatureDictionary *d)
 
virtual ~CTreeQueryExec ()
 
void SetTree (CPhyloTree *t)
 Set current node for query execution. More...
 
TBioTreeFeatureId GetFeatureIdNoCase (const string &feature_name, const CBioTreeFeatureDictionary *dict) const
 Returns id of a registred tree feature based on case-insensitive compare or -1 if feature does not exist. More...
 
virtual TFieldID GetIdentifier (const std::string &identifier)
 Get biotree feature ID for identifier or return TFieldID(-1) More...
 
virtual bool HasIdentifier (const std::string &identifier)
 Search for 'identifier' in dictionary and return true if it exists. More...
 
virtual CQueryParseNode::EType IdentifierType (const std::string &)
 Some applications may know the type of an identifier. More...
 
virtual void CallFunction (const string &name, CQueryParseTree::TNode &node)
 Extend this function to look up and invoke functions that appear in the query. More...
 
virtual void EvalStart ()
 Move to the first row for eval, return false if table empty. More...
 
virtual bool EvalNext (CQueryParseTree &qtree)
 Move to the next row for eval, return false if table size < m_EvalRow+1. More...
 
virtual bool EvalNext (macro::CMacroRep &m)
 
virtual bool EvalComplete ()
 
virtual void GetFunctionNames (macro::CMacroParser &parser) const
 
std::vector< TTreeIdxGetTreeSelected () const
 
TTreeIdx GetCurrentIdx ()
 
CFeatureEditGetFeatureEdit ()
 
CSelectionSetEditGetSelectionEdit ()
 
bool GetTopologyChange () const
 
void DisableUndo (bool b)
 
Find and convert feature-list values in individual nodes

Search for bool 'identifier' in feature list and return if found

virtual bool ResolveIdentifier (const std::string &identifier, bool &value)
 If query has an identifier, this will resolve it in an application-specific way. More...
 
virtual bool ResolveIdentifier (const std::string &identifier, Int8 &value)
 Search for integer 'identifier' in feature list and return if found. More...
 
virtual bool ResolveIdentifier (const std::string &identifier, double &value)
 Search for float 'identifier' in feature list and return if found. More...
 
virtual bool ResolveIdentifier (const std::string &identifier, std::string &value)
 Search for string 'identifier' in feature list and return if found. More...
 
virtual bool ResolveIdentifier (const TFieldID &id, bool &value)
 Following functions look up field based on a biotree feature id. More...
 
virtual bool ResolveIdentifier (const TFieldID &id, Int8 &value)
 
virtual bool ResolveIdentifier (const TFieldID &id, double &value)
 
virtual bool ResolveIdentifier (const TFieldID &id, std::string &value)
 
- Public Member Functions inherited from CMacroQueryExec
 CMacroQueryExec ()
 
virtual ~CMacroQueryExec ()
 
void SetMacroRep (macro::CMacroRep *mr)
 
macro::CMacroRep * GetMacroRep ()
 
CRef< CQueryNodeValueGetOrCreateRTVar (const string &name)
 Gets or creates run-time vars (used in assignment in Do clause) More...
 
bool ResolveRTVar (const string &identifier, CQueryNodeValue &v)
 Return the value of RT variable in node "v". More...
 
- Public Member Functions inherited from CQueryExec
 CQueryExec ()
 
virtual ~CQueryExec ()
 
void AddFunc (CQueryParseNode::EType func_type, CQueryFunctionBase *func)
 Register function implementation. More...
 
void AddImplicitSearchFunc (CQueryFunctionBase *func)
 This is a callback for implicit search nodes Our syntax allows queries like (a=1) AND "search_term" Execution recognises "search_term" connected with logical operation represents a special case. More...
 
CQueryFunctionBaseGetImplicitSearchFunc ()
 
CQueryFunctionBaseGetFunc (CQueryParseNode::EType func_type)
 Return query function pointer (if registered). More...
 
virtual void Evaluate (CQueryParseTree &qtree)
 Run query tree evaluation. More...
 
virtual void Evaluate (CQueryParseTree &qtree, CQueryParseTree::TNode &node)
 
int GetQueriedCount () const
 
int GetExceptionCount () const
 
- Public Member Functions inherited from CObject
 CObject (void)
 Constructor. More...
 
 CObject (const CObject &src)
 Copy constructor. More...
 
virtual ~CObject (void)
 Destructor. More...
 
CObjectoperator= (const CObject &src) THROWS_NONE
 Assignment operator. More...
 
bool CanBeDeleted (void) const THROWS_NONE
 Check if object can be deleted. More...
 
bool IsAllocatedInPool (void) const THROWS_NONE
 Check if object is allocated in memory pool (not system heap) More...
 
bool Referenced (void) const THROWS_NONE
 Check if object is referenced. More...
 
bool ReferencedOnlyOnce (void) const THROWS_NONE
 Check if object is referenced only once. More...
 
void AddReference (void) const
 Add reference to object. More...
 
void RemoveReference (void) const
 Remove reference to object. More...
 
void ReleaseReference (void) const
 Remove reference without deleting object. More...
 
virtual void DoNotDeleteThisObject (void)
 Mark this object as not allocated in heap – do not delete this object. More...
 
virtual void DoDeleteThisObject (void)
 Mark this object as allocated in heap – object can be deleted. More...
 
void * operator new (size_t size)
 Define new operator for memory allocation. More...
 
void * operator new[] (size_t size)
 Define new[] operator for 'array' memory allocation. More...
 
void operator delete (void *ptr)
 Define delete operator for memory deallocation. More...
 
void operator delete[] (void *ptr)
 Define delete[] operator for memory deallocation. More...
 
void * operator new (size_t size, void *place)
 Define new operator. More...
 
void operator delete (void *ptr, void *place)
 Define delete operator. More...
 
void * operator new (size_t size, CObjectMemoryPool *place)
 Define new operator using memory pool. More...
 
void operator delete (void *ptr, CObjectMemoryPool *place)
 Define delete operator. More...
 
virtual void DebugDump (CDebugDumpContext ddc, unsigned int depth) const
 Define method for dumping debug information. More...
 
- Public Member Functions inherited from CDebugDumpable
 CDebugDumpable (void)
 
virtual ~CDebugDumpable (void)
 
void DebugDumpText (ostream &out, const string &bundle, unsigned int depth) const
 
void DebugDumpFormat (CDebugDumpFormatter &ddf, const string &bundle, unsigned int depth) const
 
void DumpToConsole (void) const
 

Protected Types

typedef map< string, ITreeMacroFunction * > TBuiltInFunctionsMap
 
- Protected Types inherited from CMacroQueryExec
typedef map< string, CRef< CQueryNodeValue > > TRTVarsMap
 
- Protected Types inherited from CQueryExec
typedef vector< CQueryFunctionBase * > TFuncReg
 

Protected Member Functions

ITreeMacroFunctionx_ResolveFunctionName (const string &name) const
 Locates function by name. More...
 
void x_ClearBuiltInFunctions ()
 Deletes function objects. More...
 
void x_EvalAdvance ()
 Moves to next node for 'EvalNext' functions. More...
 
- Protected Member Functions inherited from CMacroQueryExec
CRef< CQueryNodeValuex_LocateRTVar (const string &identifier)
 Gets the pointer to RT variable. More...
 
- Protected Member Functions inherited from CQueryExec
CQueryParseTreeGetQTree ()
 
- Protected Member Functions inherited from CObject
virtual void DeleteThis (void)
 Virtual method "deleting" this object. More...
 

Protected Attributes

TBuiltInFunctionsMap m_BuiltInFunctions
 functions More...
 
CRef< CMacroCmdCompositem_CmdComposite
 
TTreeIdx m_EvalNode
 Node currently being evaluated. More...
 
CPhyloTreem_Tree
 
std::stack< PhyloTreePointerm_NodeStack
 stack of visited nodes up the tree More...
 
const CBioTreeFeatureDictionarym_Dictionary
 Dictionary of 'features' for the tree. More...
 
std::vector< TTreeIdxm_Selected
 current set of selected nodes from the query More...
 
CRef< CFeatureEditm_FeatureEdit
 The undo/redo buffer for node properties. More...
 
bool m_TopologyChange
 If true topology changed (e.g. a node was deleted) More...
 
int m_NodeBranchDepth
 Depth in tree as an integer - number of branches between current node and root. More...
 
int m_NodeMaxChildBranchDepth
 Number of branches between the current node and it's most distant (by branch count) child. More...
 
CRef< CSelectionSetEditm_SelectionSetEdit
 Undo-redo buffer for selection sets (which are stored in biotreecontainer user data) More...
 
bool m_DisableUndo
 To disable use of undo buffer (m_FeatureEdit) More...
 
bool m_EvalDo
 Flag indicates if the work should be performed on the Do clause. More...
 
- Protected Attributes inherited from CMacroQueryExec
macro::CMacroRep * m_MacroRep { nullptr }
 
TRTVarsMap m_RTVars
 
- Protected Attributes inherited from CQueryExec
TFuncReg m_FuncReg
 
unique_ptr< CQueryFunctionBasem_ImplicitSearchFunc
 
CQueryParseTreem_QTree
 
int m_ExceptionCount
 
int m_QueriedCount
 

Additional Inherited Members

- Static Public Member Functions inherited from CObject
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (void)
 Define method to throw null pointer exception. More...
 
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (const type_info &type)
 
static EAllocFillMode GetAllocFillMode (void)
 
static void SetAllocFillMode (EAllocFillMode mode)
 
static void SetAllocFillMode (const string &value)
 Set mode from configuration parameter value. More...
 
- Static Public Member Functions inherited from CDebugDumpable
static void EnableDebugDump (bool on)
 
- Static Public Attributes inherited from CObject
static const TCount eCounterBitsCanBeDeleted = 1 << 0
 Define possible object states. More...
 
static const TCount eCounterBitsInPlainHeap = 1 << 1
 Heap signature was found. More...
 
static const TCount eCounterBitsPlaceMask
 Mask for 'in heap' state flags. More...
 
static const int eCounterStep = 1 << 2
 Skip over the "in heap" bits. More...
 
static const TCount eCounterValid = TCount(1) << (sizeof(TCount) * 8 - 2)
 Minimal value for valid objects (reference counter is zero) Must be a single bit value. More...
 
static const TCount eCounterStateMask
 Valid object, and object in heap. More...
 

Detailed Description

class CTreeQueryExec

Subclass of CQueryExec that adds functions spcific to the phylogenetic tree that allow it to extract data from the feature lists of individual nodes so that those values can be used in queries.

Definition at line 66 of file phylo_tree_query_exec.hpp.

Member Typedef Documentation

◆ TBuiltInFunctionsMap

Definition at line 158 of file phylo_tree_query_exec.hpp.

◆ TNodeType

Definition at line 71 of file phylo_tree_query_exec.hpp.

◆ TTreeIdx

Definition at line 70 of file phylo_tree_query_exec.hpp.

◆ TTreeType

Definition at line 69 of file phylo_tree_query_exec.hpp.

Constructor & Destructor Documentation

◆ CTreeQueryExec()

CTreeQueryExec::CTreeQueryExec ( const CBioTreeFeatureDictionary d)
inline

Definition at line 74 of file phylo_tree_query_exec.hpp.

◆ ~CTreeQueryExec()

CTreeQueryExec::~CTreeQueryExec ( )
virtual

Definition at line 68 of file phylo_tree_query_exec.cpp.

References x_ClearBuiltInFunctions().

Member Function Documentation

◆ CallFunction()

void CTreeQueryExec::CallFunction ( const string name,
CQueryParseTree::TNode node 
)
virtual

◆ DisableUndo()

void CTreeQueryExec::DisableUndo ( bool  b)
inline

Definition at line 155 of file phylo_tree_query_exec.hpp.

References b, and m_DisableUndo.

◆ EvalComplete()

bool CTreeQueryExec::EvalComplete ( )
virtual

Reimplemented from CQueryExec.

Definition at line 382 of file phylo_tree_query_exec.cpp.

References m_NodeStack.

◆ EvalNext() [1/2]

bool CTreeQueryExec::EvalNext ( CQueryParseTree qtree)
virtual

◆ EvalNext() [2/2]

bool CTreeQueryExec::EvalNext ( macro::CMacroRep &  m)
virtual

◆ EvalStart()

void CTreeQueryExec::EvalStart ( )
virtual

◆ GetCurrentIdx()

TTreeIdx CTreeQueryExec::GetCurrentIdx ( )
inline

Definition at line 148 of file phylo_tree_query_exec.hpp.

References m_EvalNode.

◆ GetFeatureEdit()

CFeatureEdit* CTreeQueryExec::GetFeatureEdit ( )
inline

Definition at line 150 of file phylo_tree_query_exec.hpp.

References m_FeatureEdit.

Referenced by CPhyloTreeWidget::QueryEnd().

◆ GetFeatureIdNoCase()

TBioTreeFeatureId CTreeQueryExec::GetFeatureIdNoCase ( const string feature_name,
const CBioTreeFeatureDictionary dict 
) const

Returns id of a registred tree feature based on case-insensitive compare or -1 if feature does not exist.

Definition at line 144 of file phylo_tree_query_exec.cpp.

References map_checker< Container >::begin(), NStr::CompareNocase(), map_checker< Container >::end(), and CBioTreeFeatureDictionary::GetFeatureDict().

Referenced by GetIdentifier(), HasIdentifier(), and ResolveIdentifier().

◆ GetFunctionNames()

void CTreeQueryExec::GetFunctionNames ( macro::CMacroParser &  parser) const
virtual

◆ GetIdentifier()

CTreeQueryExec::TFieldID CTreeQueryExec::GetIdentifier ( const std::string identifier)
virtual

Get biotree feature ID for identifier or return TFieldID(-1)

Reimplemented from CQueryExec.

Definition at line 277 of file phylo_tree_query_exec.cpp.

References GetFeatureIdNoCase(), and m_Dictionary.

◆ GetSelectionEdit()

CSelectionSetEdit* CTreeQueryExec::GetSelectionEdit ( )
inline

Definition at line 151 of file phylo_tree_query_exec.hpp.

References m_SelectionSetEdit.

Referenced by CPhyloTreeWidget::QueryEnd().

◆ GetTopologyChange()

bool CTreeQueryExec::GetTopologyChange ( ) const
inline

Definition at line 153 of file phylo_tree_query_exec.hpp.

References m_TopologyChange.

Referenced by CPhyloTreeWidget::QueryEnd().

◆ GetTreeSelected()

std::vector<TTreeIdx> CTreeQueryExec::GetTreeSelected ( ) const
inline

Definition at line 147 of file phylo_tree_query_exec.hpp.

References m_Selected.

Referenced by CPhyloTreeDataSource::SetQueryResults().

◆ HasIdentifier()

bool CTreeQueryExec::HasIdentifier ( const std::string identifier)
virtual

Search for 'identifier' in dictionary and return true if it exists.

This does not mean that the value is defined for a particular node.

Reimplemented from CQueryExec.

Definition at line 282 of file phylo_tree_query_exec.cpp.

References GetFeatureIdNoCase(), and m_Dictionary.

◆ IdentifierType()

virtual CQueryParseNode::EType CTreeQueryExec::IdentifierType ( const std::string )
inlinevirtual

Some applications may know the type of an identifier.

This hook should be overriden to return an identifier's type, when available. Return one of eIntConst, eBoolConst, eFloatConst, eString, or eNotSet.

Reimplemented from CQueryExec.

Definition at line 130 of file phylo_tree_query_exec.hpp.

References CQueryParseNode::eNotSet.

◆ ResolveIdentifier() [1/8]

bool CTreeQueryExec::ResolveIdentifier ( const std::string ,
bool  
)
virtual

If query has an identifier, this will resolve it in an application-specific way.

Returns true if resolved, with the data item's value in 'value'. Using field identifiers, if available, such as column numbers or biotree feature IDs will be faster.

Reimplemented from CQueryExec.

Definition at line 160 of file phylo_tree_query_exec.cpp.

References CPhyloTree::GetFeatureDict(), GetFeatureIdNoCase(), m_Tree, and rapidjson::value.

Referenced by ResolveIdentifier().

◆ ResolveIdentifier() [2/8]

bool CTreeQueryExec::ResolveIdentifier ( const std::string identifier,
double &  value 
)
virtual

Search for float 'identifier' in feature list and return if found.

Reimplemented from CQueryExec.

Definition at line 180 of file phylo_tree_query_exec.cpp.

References CPhyloTree::GetFeatureDict(), GetFeatureIdNoCase(), m_Tree, ResolveIdentifier(), and rapidjson::value.

◆ ResolveIdentifier() [3/8]

bool CTreeQueryExec::ResolveIdentifier ( const std::string identifier,
Int8 value 
)
virtual

Search for integer 'identifier' in feature list and return if found.

Reimplemented from CQueryExec.

Definition at line 170 of file phylo_tree_query_exec.cpp.

References CPhyloTree::GetFeatureDict(), GetFeatureIdNoCase(), m_Tree, ResolveIdentifier(), and rapidjson::value.

◆ ResolveIdentifier() [4/8]

bool CTreeQueryExec::ResolveIdentifier ( const std::string identifier,
std::string value 
)
virtual

Search for string 'identifier' in feature list and return if found.

Reimplemented from CQueryExec.

Definition at line 190 of file phylo_tree_query_exec.cpp.

References CPhyloTree::GetFeatureDict(), GetFeatureIdNoCase(), m_Tree, ResolveIdentifier(), and rapidjson::value.

◆ ResolveIdentifier() [5/8]

bool CTreeQueryExec::ResolveIdentifier ( const TFieldID id,
bool value 
)
virtual

Following functions look up field based on a biotree feature id.

Reimplemented from CQueryExec.

Definition at line 200 of file phylo_tree_query_exec.cpp.

References CTreeModel< TNode >::GetNode(), m_EvalNode, m_Tree, NStr::StringToBool(), and rapidjson::value.

◆ ResolveIdentifier() [6/8]

bool CTreeQueryExec::ResolveIdentifier ( const TFieldID id,
double &  value 
)
virtual

◆ ResolveIdentifier() [7/8]

bool CTreeQueryExec::ResolveIdentifier ( const TFieldID id,
Int8 value 
)
virtual

◆ ResolveIdentifier() [8/8]

bool CTreeQueryExec::ResolveIdentifier ( const TFieldID id,
std::string value 
)
virtual

Reimplemented from CQueryExec.

Definition at line 264 of file phylo_tree_query_exec.cpp.

References CTreeModel< TNode >::GetNode(), m_EvalNode, m_Tree, and rapidjson::value.

◆ SetTree()

void CTreeQueryExec::SetTree ( CPhyloTree t)

Set current node for query execution.

Setting up the functions.

Definition at line 76 of file phylo_tree_query_exec.cpp.

References m_BuiltInFunctions, m_CmdComposite, m_Tree, CRef< C, Locker >::Reset(), t, and x_ClearBuiltInFunctions().

Referenced by CPhyloTreeDataSource::GetQueryExec().

◆ x_ClearBuiltInFunctions()

void CTreeQueryExec::x_ClearBuiltInFunctions ( )
protected

◆ x_EvalAdvance()

void CTreeQueryExec::x_EvalAdvance ( )
protected

◆ x_ResolveFunctionName()

ITreeMacroFunction * CTreeQueryExec::x_ResolveFunctionName ( const string name) const
protected

Locates function by name.

Definition at line 289 of file phylo_tree_query_exec.cpp.

References map_checker< Container >::end(), map_checker< Container >::find(), m_BuiltInFunctions, and NStr::ToUpper().

Referenced by CallFunction().

Member Data Documentation

◆ m_BuiltInFunctions

TBuiltInFunctionsMap CTreeQueryExec::m_BuiltInFunctions
protected

◆ m_CmdComposite

CRef<CMacroCmdComposite> CTreeQueryExec::m_CmdComposite
protected

Definition at line 170 of file phylo_tree_query_exec.hpp.

Referenced by CallFunction(), and SetTree().

◆ m_Dictionary

const CBioTreeFeatureDictionary* CTreeQueryExec::m_Dictionary
protected

Dictionary of 'features' for the tree.

Definition at line 193 of file phylo_tree_query_exec.hpp.

Referenced by GetIdentifier(), and HasIdentifier().

◆ m_DisableUndo

bool CTreeQueryExec::m_DisableUndo
protected

To disable use of undo buffer (m_FeatureEdit)

Definition at line 216 of file phylo_tree_query_exec.hpp.

Referenced by DisableUndo(), and EvalNext().

◆ m_EvalDo

bool CTreeQueryExec::m_EvalDo
protected

Flag indicates if the work should be performed on the Do clause.

Definition at line 219 of file phylo_tree_query_exec.hpp.

Referenced by CallFunction(), and EvalNext().

◆ m_EvalNode

TTreeIdx CTreeQueryExec::m_EvalNode
protected

Node currently being evaluated.

Definition at line 173 of file phylo_tree_query_exec.hpp.

Referenced by CallFunction(), EvalNext(), EvalStart(), GetCurrentIdx(), ResolveIdentifier(), and x_EvalAdvance().

◆ m_FeatureEdit

CRef<CFeatureEdit> CTreeQueryExec::m_FeatureEdit
protected

The undo/redo buffer for node properties.

We don't want to update this in CGI since it is not needed and would slow things down

Definition at line 200 of file phylo_tree_query_exec.hpp.

Referenced by EvalNext(), EvalStart(), and GetFeatureEdit().

◆ m_NodeBranchDepth

int CTreeQueryExec::m_NodeBranchDepth
protected

Depth in tree as an integer - number of branches between current node and root.

Definition at line 206 of file phylo_tree_query_exec.hpp.

Referenced by CallFunction(), EvalStart(), and x_EvalAdvance().

◆ m_NodeMaxChildBranchDepth

int CTreeQueryExec::m_NodeMaxChildBranchDepth
protected

Number of branches between the current node and it's most distant (by branch count) child.

Definition at line 209 of file phylo_tree_query_exec.hpp.

Referenced by CallFunction(), EvalStart(), and x_EvalAdvance().

◆ m_NodeStack

std::stack<PhyloTreePointer> CTreeQueryExec::m_NodeStack
protected

stack of visited nodes up the tree

Definition at line 190 of file phylo_tree_query_exec.hpp.

Referenced by EvalComplete(), EvalStart(), and x_EvalAdvance().

◆ m_Selected

std::vector<TTreeIdx> CTreeQueryExec::m_Selected
protected

current set of selected nodes from the query

Definition at line 196 of file phylo_tree_query_exec.hpp.

Referenced by EvalNext(), EvalStart(), and GetTreeSelected().

◆ m_SelectionSetEdit

CRef<CSelectionSetEdit> CTreeQueryExec::m_SelectionSetEdit
protected

Undo-redo buffer for selection sets (which are stored in biotreecontainer user data)

Definition at line 213 of file phylo_tree_query_exec.hpp.

Referenced by EvalStart(), and GetSelectionEdit().

◆ m_TopologyChange

bool CTreeQueryExec::m_TopologyChange
protected

If true topology changed (e.g. a node was deleted)

Definition at line 203 of file phylo_tree_query_exec.hpp.

Referenced by EvalNext(), EvalStart(), and GetTopologyChange().

◆ m_Tree

CPhyloTree* CTreeQueryExec::m_Tree
protected

The documentation for this class was generated from the following files:
Modified on Fri Sep 20 14:58:30 2024 by modify_doxy.py rev. 669887