00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2011 by the OpenStructure authors 00005 // 00006 // This library is free software; you can redistribute it and/or modify it under 00007 // the terms of the GNU Lesser General Public License as published by the Free 00008 // Software Foundation; either version 3.0 of the License, or (at your option) 00009 // any later version. 00010 // This library is distributed in the hope that it will be useful, but WITHOUT 00011 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00013 // details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this library; if not, write to the Free Software Foundation, Inc., 00017 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 //------------------------------------------------------------------------------ 00019 #ifndef OST_QUERY_STATE_HH 00020 #define OST_QUERY_STATE_HH 00021 00022 /* 00023 Author: Marco Biasini 00024 */ 00025 00026 #include <ost/geom/geom.hh> 00027 00028 #include <ost/mol/impl/query_impl_fw.hh> 00029 #include <ost/mol/impl/query_ast_fw.hh> 00030 00031 #include <ost/mol/handle_type_fw.hh> 00032 #include <boost/logic/tribool.hpp> 00033 #include <ost/mol/impl/entity_impl_fw.hh> 00034 #include <ost/mol/impl/chain_impl_fw.hh> 00035 #include <ost/mol/impl/residue_impl_fw.hh> 00036 #include <ost/mol/impl/atom_impl_fw.hh> 00037 00038 #include "property_id.hh" 00039 00040 namespace ost { namespace mol { 00041 00042 class EntityHandle; 00043 class EntityView; 00044 struct LazilyBoundData; 00045 struct LazilyBoundRef; 00046 00050 class DLLEXPORT_OST_MOL QueryState { 00051 friend class impl::QueryImpl; 00052 public: 00053 bool IsAtomSelected(const AtomHandle& atom); 00054 00055 bool IsResidueSelected(const ResidueHandle& residue); 00056 00057 bool IsChainSelected(const ChainHandle& chain); 00058 00060 boost::logic::tribool EvalChain(const impl::ChainImplPtr& c); 00061 00063 boost::logic::tribool EvalResidue(const impl::ResidueImplPtr& r); 00064 00066 boost::logic::tribool EvalAtom(const impl::AtomImplPtr& a); 00067 00068 void Reset(Prop::Level level); 00069 00070 ~QueryState(); 00071 protected: 00073 QueryState(const impl::QueryImpl& query, const EntityHandle& ref); 00074 QueryState(const impl::QueryImpl& query, const EntityView& ref); 00075 QueryState(); 00076 00077 const LazilyBoundRef& GetBoundObject(int i) const; 00079 boost::logic::tribool EvalStack(Prop::Level level); 00080 00081 private: 00082 bool do_within(const geom::Vec3& pos, const impl::WithinParam& p, 00083 impl::CompOP op); 00084 std::vector<boost::logic::tribool> s_; 00085 std::vector<boost::logic::tribool> value_stack_; 00086 boost::shared_ptr<LazilyBoundData> r_; 00087 const impl::QueryImpl& q_; 00088 }; 00089 00090 }} //ns 00091 00092 #endif