AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
operator_id.h
1
#ifndef OPERATOR_ID_H
2
#define OPERATOR_ID_H
3
4
#include "downward/utils/hash.h"
5
6
#include <iostream>
7
8
/*
9
OperatorIDs are used to define an operator that belongs to a given
10
planning task. These IDs are meant to be compact and efficient to use.
11
They can be thought of as a type-safe replacement for "int" for the
12
purpose of referring to an operator.
13
14
Because of their efficiency requirements, they do *not* store which
15
task they belong to, and it is the user's responsibility not to mix
16
OperatorIDs that belong to different tasks.
17
18
OperatorIDs can only refer to *operators*, not to *axioms*. This is
19
by design: using OperatorID clearly communicates that only operators
20
are appropriate in a given place and it is an error to use an axiom.
21
We also considered introducing a class that can refer to operators or
22
axioms (suggested names were OperatorOrAxiomID and ActionID, introducing
23
the convention that "action" stands for "operator or axiom"), but so
24
far we have not found a use case for it.
25
*/
26
class
OperatorID {
27
int
index;
28
29
public
:
30
explicit
OperatorID(
int
index)
31
: index(index)
32
{
33
}
34
35
static
const
OperatorID no_operator;
36
37
int
get_index()
const
{
return
index; }
38
39
bool
operator==(
const
OperatorID& other)
const
40
{
41
return
index == other.index;
42
}
43
44
bool
operator!=(
const
OperatorID& other)
const
{
return
!(*
this
== other); }
45
46
bool
operator<(
const
OperatorID& other)
const
47
{
48
return
index < other.index;
49
}
50
51
int
hash()
const
{
return
index; }
52
};
53
54
std::ostream& operator<<(std::ostream& os, OperatorID
id
);
55
56
namespace
utils {
57
inline
void
feed(HashState& hash_state, OperatorID
id
)
58
{
59
feed(hash_state,
id
.hash());
60
}
61
}
// namespace utils
62
63
#endif
downward
operator_id.h
Generated on Tue Jan 7 2025 for AI 24/25 Project Software by
1.12.0