dlvhex
2.5.0
|
00001 /* dlvhex -- Answer-Set Programming with external interfaces. 00002 * Copyright (C) 2005-2007 Roman Schindlauer 00003 * Copyright (C) 2006-2015 Thomas Krennwallner 00004 * Copyright (C) 2009-2016 Peter Schüller 00005 * Copyright (C) 2011-2016 Christoph Redl 00006 * Copyright (C) 2015-2016 Tobias Kaminski 00007 * Copyright (C) 2015-2016 Antonius Weinzierl 00008 * 00009 * This file is part of dlvhex. 00010 * 00011 * dlvhex is free software; you can redistribute it and/or modify it 00012 * under the terms of the GNU Lesser General Public License as 00013 * published by the Free Software Foundation; either version 2.1 of 00014 * the License, or (at your option) any later version. 00015 * 00016 * dlvhex is distributed in the hope that it will be useful, but 00017 * WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with dlvhex; if not, write to the Free Software 00023 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00024 * 02110-1301 USA. 00025 */ 00026 00035 #ifndef PREDICATEMASK_HPP_INCLUDED__27012011 00036 #define PREDICATEMASK_HPP_INCLUDED__27012011 00037 00038 #include "dlvhex2/PlatformDefinitions.h" 00039 #include "dlvhex2/fwd.h" 00040 #include "dlvhex2/ID.h" 00041 00042 #include <boost/thread/mutex.hpp> 00043 00044 #include <set> 00045 00046 DLVHEX_NAMESPACE_BEGIN 00047 00049 class DLVHEX_EXPORT PredicateMask 00050 { 00051 public: 00053 PredicateMask(); 00055 ~PredicateMask(); 00056 00064 PredicateMask(const PredicateMask& p); 00072 PredicateMask& operator=(const PredicateMask& p); 00073 00076 void setRegistry(RegistryPtr registry); 00077 00083 void addPredicate(ID pred); 00084 00086 void updateMask(); 00087 00090 InterpretationConstPtr mask() const 00091 { return maski; } 00092 00093 protected: 00097 std::set<IDAddress> predicates; 00099 mutable InterpretationPtr maski; 00101 mutable IDAddress knownAddresses; 00102 00104 boost::mutex updateMutex; 00105 }; 00106 00110 class DLVHEX_EXPORT ExternalAtomMask : public PredicateMask 00111 { 00112 private: 00114 const ProgramCtx* ctx; 00116 const ExternalAtom* eatom; 00118 mutable InterpretationPtr outputAtoms; 00120 mutable InterpretationPtr auxInputMask; 00122 mutable Tuple preparedTuple; 00124 mutable Tuple workTuple; 00125 protected: 00129 bool matchOutputAtom(const Tuple& togatom); 00130 public: 00132 ExternalAtomMask(); 00134 ~ExternalAtomMask(); 00135 00140 void setEAtom(const ProgramCtx& ctx, const ExternalAtom& eatom, const std::vector<ID>& groundidb); 00145 void addOutputAtoms(InterpretationConstPtr intr); 00146 virtual void updateMask(); 00149 const InterpretationConstPtr getAuxInputMask() const; 00150 }; 00151 00152 DLVHEX_NAMESPACE_END 00153 #endif // PREDICATEMASK_HPP_INCLUDED__27012011 00154 00155 // vim:expandtab:ts=4:sw=4: 00156 // mode: C++ 00157 // End: