-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathId.hpp
More file actions
71 lines (62 loc) · 1.56 KB
/
Id.hpp
File metadata and controls
71 lines (62 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef ISL_CXX_Id_IMPL_H
#define ISL_CXX_Id_IMPL_H
#include "isl/Id.h"
#include "isl/Ctx.hpp"
#include "isl/Format.h"
#include "isl/IslBase.h"
#include "isl/IslException.h"
#include <string>
#include <cassert>
namespace isl {
inline isl_id *Id::GetCopy() const {
return isl_id_copy((isl_id *)This);
}
inline Id &Id::operator=(const Id &Other) {
isl_id *New = Other.GetCopy();
ctx = Other.Context();
isl_id_free((isl_id *)This);
This = New;
return *this;
}
inline Id Id::alloc(const Ctx &ctx, std::string name, void * user) {
const Ctx &_ctx = ctx.Context();
_ctx.lock();
isl_id *That = isl_id_alloc((ctx.Get()), name.c_str(), user);
_ctx.unlock();
if (_ctx.hasError()) {
handleError("isl_id_alloc returned a NULL pointer.");
}
return Id(_ctx, That);
}
inline Id::~Id() {
isl_id_free((isl_id *)This);
This = nullptr;
}
/// rief Release ownership of the wrapped object.
///
/// You are on your own now buddy.
/// The wrapper cannot be used anymore after calling Give()
///
///@return the wrapped isl object.
inline isl_id *Id::Give() {
isl_id *res = (isl_id *)This;
This = nullptr;
return res;
}
/// \brief Unwrap the stored isl object.
/// \returns A the wrapped isl object.
inline isl_id *Id::Get() const { return (isl_id *)This;
}
inline std::string Id::getName() const {
ctx.lock();
const char * res = isl_id_get_name((*this).Get());
ctx.unlock();
std::string res_;
if (ctx.hasError()) {
handleError("isl_id_get_name returned a NULL pointer.");
}
res_ = res;
return res_;
}
} // namespace isl
#endif //ISL_CXX_Id_IMPL_H