P4C
The P4 Compiler
Loading...
Searching...
No Matches
tx_score.h
1
19#ifndef BF_P4C_PHV_V2_TX_SCORE_H_
20#define BF_P4C_PHV_V2_TX_SCORE_H_
21
22#include "bf-p4c/phv/utils/utils.h"
23
24namespace PHV {
25namespace v2 {
26
28class TxScore {
29 public:
30 virtual bool better_than(const TxScore *other) const = 0;
31 virtual std::string str() const = 0;
32};
33
36 public:
37 virtual TxScore *make(const Transaction &tx) const = 0;
38};
39
42class NilTxScore : public TxScore {
43 public:
44 bool better_than(const TxScore *) const override { return false; }
45 std::string str() const override { return "nil"; };
46};
47
50 public:
51 TxScore *make(const Transaction &) const override { return new NilTxScore(); }
52};
53
55class MinPackTxScore : public TxScore {
56 public:
57 // number of container that is used for packing.
58 int n_packed = 0;
59 bool use_mocha_or_dark = false;
60 MinPackTxScore(int n_packed, bool use_mocha_or_dark)
61 : n_packed(n_packed), use_mocha_or_dark(use_mocha_or_dark) {}
62 bool better_than(const TxScore *other) const override;
63 std::string str() const override;
64};
65
68 public:
69 TxScore *make(const Transaction &tx) const override;
70};
71
72} // namespace v2
73} // namespace PHV
74
75#endif /* BF_P4C_PHV_V2_TX_SCORE_H_ */
Definition phv/utils/utils.h:561
MinPackTxScore prefers minimal packing.
Definition tx_score.h:55
factory class for MinPackTxScore.
Definition tx_score.h:67
Definition tx_score.h:42
NilTxScoreMaker is a factory class to make nil score.
Definition tx_score.h:49
TxScore is the interface of an allocation score.
Definition tx_score.h:28
TxScoreMaker is the interface of the factory class of TxScore.
Definition tx_score.h:35
The namespace encapsulating PHV-related stuff.
Definition gateway.h:32