1 /********************* */
2 /*! \file atom_requests.h
4 ** Top contributors (to current version):
5 ** Dejan Jovanovic, Morgan Deters, Paul Meng
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2017 by the authors listed in the file AUTHORS
8 ** in the top-level source directory) and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
12 ** \brief [[ Add one-line brief description here ]]
14 ** [[ Add lengthier description here ]]
15 ** \todo document this file
18 #include "cvc4_private.h"
22 #include "expr/node.h"
23 #include "theory/theory.h"
24 #include "context/cdlist.h"
25 #include "context/cdhashset.h"
26 #include "context/cdhashmap.h"
34 /** Which atom and where to send it */
38 /** Where to send it */
39 theory::TheoryId toTheory
;
41 Request(TNode atom
, theory::TheoryId toTheory
)
42 : atom(atom
), toTheory(toTheory
) {}
44 : toTheory(theory::THEORY_LAST
)
47 bool operator == (const Request
& other
) const {
48 return atom
== other
.atom
&& toTheory
== other
.toTheory
;
57 AtomRequests(context::Context
* context
);
59 /** Mark the atom to be sent to a theory, when the trigger atom gets assigned */
60 void add(TNode triggerAtom
, TNode atomToSend
, theory::TheoryId toTheory
);
62 /** Returns true if the node is a trigger and has a list of atoms to send */
63 bool isTrigger(TNode atom
) const;
65 /** Indices in lists */
66 typedef size_t element_index
;
69 const AtomRequests
& requests
;
71 friend class AtomRequests
;
72 atom_iterator(const AtomRequests
& requests
, element_index start
)
73 : requests(requests
), index(start
) {}
75 /** Is this iterator done */
77 /** Go to the next element */
79 /** Get the actual request */
80 const Request
& get() const;
83 atom_iterator
getAtomIterator(TNode trigger
) const;
87 struct RequestHashFunction
{
88 size_t operator () (const Request
& r
) const {
93 /** Set of all requests so we don't add twice */
94 context::CDHashSet
<Request
, RequestHashFunction
> d_allRequests
;
96 static const element_index null_index
= -1;
99 /** Current request */
101 /** Previous request */
102 element_index previous
;
104 Element(const Request
& request
, element_index previous
)
105 : request(request
), previous(previous
)
109 /** We index the requests in this vector, it's a list */
110 context::CDList
<Element
> d_requests
;
112 typedef context::CDHashMap
<Node
, element_index
, NodeHashFunction
> trigger_to_list_map
;
114 /** Map from triggers, to the list of elements they trigger */
115 trigger_to_list_map d_triggerToRequestMap
;
117 /** Get the list index of the trigger */
118 element_index
getList(TNode trigger
) const;