ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
ObjectId.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include "ObjectHandle.hpp"
23
24#include <boost/serialization/access.hpp>
25
26#include <cstdint>
27#include <functional>
28
29namespace ScriptInterface {
30
31/**
32 * @brief Strongly typed integer type to hold a unique identifier
33 * for a @ref ObjectHandle object, using its memory address.
34 * Therefore, this object can only be constructed from a
35 * @ref ObjectHandle object on the head node.
36 */
37struct ObjectId {
38#ifdef UINTPTR_MAX
39 using value_type = std::uintptr_t;
40#else
41 using value_type = std::size_t;
42 static_assert(sizeof(void *) <= sizeof(value_type));
43#endif
44
45 ObjectId() = default;
47
48 constexpr bool operator==(ObjectId const &) const = default;
49 constexpr bool operator!=(ObjectId const &) const = default;
50
52
53private:
55
56 template <typename Archive>
57 void serialize(Archive &ar, unsigned const /*version*/) {
58 ar & m_id;
59 }
60};
61
62} // namespace ScriptInterface
63
64namespace std {
65template <> struct hash<ScriptInterface::ObjectId> {
66 std::size_t operator()(ScriptInterface::ObjectId const &oid) const noexcept {
67 return std::hash<ScriptInterface::ObjectId::value_type>{}(oid.m_id);
68 }
69};
70} // namespace std
Base class for interface handles.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
STL namespace.
Strongly typed integer type to hold a unique identifier for a ObjectHandle object,...
Definition ObjectId.hpp:37
constexpr bool operator==(ObjectId const &) const =default
ObjectId(ObjectHandle const *p)
Definition ObjectId.hpp:46
constexpr bool operator!=(ObjectId const &) const =default
friend class boost::serialization::access
Definition ObjectId.hpp:54