NCBI C++ ToolKit
biotree_selection.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_OBJUTILS___BIOTREE_SELECTION__HPP
2 #define GUI_OBJUTILS___BIOTREE_SELECTION__HPP
3 
4 /* $Id: biotree_selection.hpp 38774 2017-06-16 15:57:03Z katargir $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Author: Vladislav Evgeniev
30  *
31  *
32  */
33 
34 /// @file biotree_selection.hpp
35 /// Defines CBioTreeSelection, class used to broadcast selected tree nodes between views.
36 
37 #include <vector>
38 #include <map>
39 #include <string>
40 #include <gui/gui_export.h>
43 #include <objects/biotree/Node.hpp>
45 
47 
48 // Class used to broadcast selected tree nodes between views.
50  public CObject
51 {
52 public:
53  /// Vector of node IDs
54  typedef std::vector<objects::CNode::TId> TNodeIdsVector;
55 
56  /// Constructor
57  /// @param[in] bioTree
58  /// Reference to a CBioTreeContainer.
59  /// @param[in] nodesCount
60  /// Number of nodes to be stored
62 
63  /// Returns the BioTree
64  /// @return
65  /// CBioTreeContainer
66  CConstRef<objects::CBioTreeContainer> GetBioTree() const { return m_BioTreeContainer; }
67 
68  /// Returns const list of selected nodes
69  /// @return
70  /// TNodeIdsVector
71  const TNodeIdsVector& GetNodeIds() const { return m_NodeIds; }
72 
73  /// Returns the list of selected nodes
74  /// @return
75  /// TNodeIdsVector
76  TNodeIdsVector& GetNodeIds() { return m_NodeIds; }
77 
78  /// Returns const list of explicitly selected nodes
79  /// @return
80  /// TNodeIdsVector
81  const TNodeIdsVector& GetExplicitlySelectedNodeIds() const { return m_ExplicitlySelectedNodeIds; }
82 
83  /// Returns the list of explicitly selected nodes
84  /// @return
85  /// TNodeIdsVector
86  TNodeIdsVector& GetExplicitlySelectedNodeIds() { return m_ExplicitlySelectedNodeIds; }
87 
88  /// Checks if the BioTree has the specified feature
89  /// @param[in] feature
90  /// Reference to a string, holding the name of the feature.
91  /// @return
92  /// true if the tree has the specified feature, false otherwise.
93  bool HasFeature(const std::string& feature) const;
94 
95  /// Gets the id of the specified feature
96  /// @param[in] feature
97  /// Reference to a string, holding the name of the feature.
98  /// @return
99  /// TId of the feature if found, false otherwise
100  objects::CFeatureDescr::TId GetFeatureId(const std::string& feature) const;
101  /// Gets the value of a feature for the specified node id
102  /// @param[in] nodeId
103  /// The ID of the node, who's feature's value to return.
104  /// @param[in] featureId
105  /// The ID of the feature, who's value to return.
106  /// @return
107  /// The value of the feature as string if it was found, empty string otherwise.
108  std::string GetFeatureValue(objects::CNode::TId nodeId, objects::CFeatureDescr::TId featureId) const;
109 
110 private:
111  /// Gets the value of a feature for the specified node
112  /// @param[in] node
113  /// The node, who's feature's value to return.
114  /// @param[in] featureId
115  /// The ID of the feature, who's value to return.
116  /// @return
117  /// The value of the feature as string if it was found, empty string otherwise.
118  std::string GetFeatureValue(const objects::CNode& node, objects::CFeatureDescr::TId featureId) const;
119 
120 private:
121  /// BioTree
123  /// Selected nodes
125  /// Nodes user actually clicked on or which were selected in a query. This does
126  /// not include parents or children of selected nodes and is maintained separately
127  /// so that user can iterate over the explicit selection set.
129  typedef std::map<std::string, objects::CFeatureDescr::TId> TStringFeatIdMap;
130  typedef std::map<objects::CNode::TId, const objects::CNode*> TNodeIdNodeMap;
131  //// Map of feature names to ids
133  /// Map od node ids to nodes
135 };
136 
138 
139 #endif /// GUI_OBJUTILS___BIOTREE_SELECTION__HPP
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
TNodeIdNodeMap m_NodesMap
Map od node ids to nodes.
TNodeIdsVector & GetNodeIds()
Returns the list of selected nodes.
const TNodeIdsVector & GetNodeIds() const
Returns const list of selected nodes.
std::vector< objects::CNode::TId > TNodeIdsVector
Vector of node IDs.
std::map< std::string, objects::CFeatureDescr::TId > TStringFeatIdMap
CConstRef< objects::CBioTreeContainer > m_BioTreeContainer
BioTree.
const TNodeIdsVector & GetExplicitlySelectedNodeIds() const
Returns const list of explicitly selected nodes.
std::string GetFeatureValue(const objects::CNode &node, objects::CFeatureDescr::TId featureId) const
Gets the value of a feature for the specified node.
std::map< objects::CNode::TId, const objects::CNode * > TNodeIdNodeMap
TNodeIdsVector & GetExplicitlySelectedNodeIds()
Returns the list of explicitly selected nodes.
std::string GetFeatureValue(objects::CNode::TId nodeId, objects::CFeatureDescr::TId featureId) const
Gets the value of a feature for the specified node id.
TNodeIdsVector m_ExplicitlySelectedNodeIds
Nodes user actually clicked on or which were selected in a query.
TStringFeatIdMap m_FeatIdsMap
TNodeIdsVector m_NodeIds
Selected nodes.
CConstRef< objects::CBioTreeContainer > GetBioTree() const
Returns the BioTree.
CObject –.
Definition: ncbiobj.hpp:180
string
Definition: cgiapp.hpp:687
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIOBJUTILS_EXPORT
Definition: gui_export.h:512
Defines to provide correct exporting from DLLs in Windows.
Modified on Sun Mar 03 03:12:16 2024 by modify_doxy.py rev. 669887