OISEAU
A modern DGTD framework
Loading...
Searching...
No Matches
field.hpp
1// Copyright (C) 2026 Tiago V. L. Amorim (@tiagovla)
2//
3// This file is part of oiseau (https://github.com/tiagovla/oiseau)
4//
5// SPDX-License-Identifier: GPL-3.0-or-later
6
7#pragma once
8
9#include <memory>
10#include <stdexcept>
11#include <string>
12#include <utility>
13
14namespace oiseau::dg {
15
20class Field {
21 public:
22 explicit Field(std::string name) : m_identity(std::make_shared<const Identity>(std::move(name))) {
23 if (m_identity->name.empty()) {
24 throw std::invalid_argument("Field name cannot be empty");
25 }
26 }
27
28 const std::string& name() const { return m_identity->name; }
29
30 bool same_as(const Field& other) const { return m_identity == other.m_identity; }
31
32 private:
33 struct Identity {
34 explicit Identity(std::string field_name) : name(std::move(field_name)) {}
35 std::string name;
36 };
37
38 std::shared_ptr<const Identity> m_identity;
39};
40
41} // namespace oiseau::dg