GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/expr/proof_set.h Lines: 7 7 100.0 %
Date: 2021-03-23 Branches: 8 14 57.1 %

Line Exec Source
1
/*********************                                                        */
2
/*! \file proof_set.h
3
 ** \verbatim
4
 ** Top contributors (to current version):
5
 **   Gereon Kremer, Andrew Reynolds
6
 ** This file is part of the CVC4 project.
7
 ** Copyright (c) 2009-2021 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
11
 **
12
 ** \brief Proof set utility
13
 **/
14
15
#include "cvc4_private.h"
16
17
#ifndef CVC4__EXPR__PROOF_SET_H
18
#define CVC4__EXPR__PROOF_SET_H
19
20
#include <memory>
21
22
#include "context/cdlist.h"
23
#include "context/context.h"
24
#include "expr/proof_node_manager.h"
25
26
namespace CVC4 {
27
28
/**
29
 * A (context-dependent) set of proofs, which is used for memory
30
 * management purposes.
31
 */
32
template <typename T>
33
30808
class CDProofSet
34
{
35
 public:
36
30811
  CDProofSet(ProofNodeManager* pnm,
37
             context::Context* c,
38
             std::string namePrefix = "Proof")
39
30811
      : d_pnm(pnm), d_proofs(c), d_namePrefix(namePrefix)
40
  {
41
30811
  }
42
  /**
43
   * Allocate a new proof.
44
   *
45
   * This returns a fresh proof object that remains alive in the context given
46
   * to this class. Internally, this adds a new proof of type T to a
47
   * context-dependent list of proofs and passes the following arguments to the
48
   * T constructor:
49
   *   pnm, args..., name
50
   * where pnm is the proof node manager
51
   * provided to this proof set upon construction, args... are the arguments to
52
   * allocateProof() and name is the namePrefix with an appended index.
53
   */
54
  template <typename... Args>
55
2287
  T* allocateProof(Args&&... args)
56
  {
57
2287
    d_proofs.push_back(std::make_shared<T>(
58
        d_pnm,
59
        std::forward<Args>(args)...,
60
        d_namePrefix + "_" + std::to_string(d_proofs.size())));
61
2287
    return d_proofs.back().get();
62
  }
63
64
 protected:
65
  /** The proof node manager */
66
  ProofNodeManager* d_pnm;
67
  /** A context-dependent list of lazy proofs. */
68
  context::CDList<std::shared_ptr<T>> d_proofs;
69
  /** The name prefix of the lazy proofs */
70
  std::string d_namePrefix;
71
};
72
73
}  // namespace CVC4
74
75
#endif /* CVC4__EXPR__LAZY_PROOF_SET_H */