OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
query_state.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_QUERY_STATE_HH
20 #define OST_QUERY_STATE_HH
21 
22 /*
23  Author: Marco Biasini
24  */
25 
26 #include <ost/geom/geom.hh>
27 
30 
32 #include <boost/logic/tribool.hpp>
37 
38 #include "property_id.hh"
39 
40 namespace ost { namespace mol {
41 
42 class EntityHandle;
43 class EntityView;
44 struct LazilyBoundData;
45 struct LazilyBoundRef;
46 
51  friend class impl::QueryImpl;
52 public:
53  bool IsAtomSelected(const AtomHandle& atom);
54 
55  bool IsResidueSelected(const ResidueHandle& residue);
56 
57  bool IsChainSelected(const ChainHandle& chain);
58 
60  boost::logic::tribool EvalChain(const impl::ChainImplPtr& c);
61 
63  boost::logic::tribool EvalResidue(const impl::ResidueImplPtr& r);
64 
66  boost::logic::tribool EvalAtom(const impl::AtomImplPtr& a);
67 
68  void Reset(Prop::Level level);
69 
70  ~QueryState();
71 protected:
73  QueryState(const impl::QueryImpl& query, const EntityHandle& ref);
74  QueryState(const impl::QueryImpl& query, const EntityView& ref);
75  QueryState();
76 
77  const LazilyBoundRef& GetBoundObject(int i) const;
79  boost::logic::tribool EvalStack(Prop::Level level);
80 
81 private:
82  bool do_within(const geom::Vec3& pos, const impl::WithinParam& p,
83  impl::CompOP op);
84  std::vector<boost::logic::tribool> s_;
85  std::vector<boost::logic::tribool> value_stack_;
86  boost::shared_ptr<LazilyBoundData> r_;
87  const impl::QueryImpl& q_;
88 };
89 
90 }} //ns
91 
92 #endif