aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/types/IdentifierRegistry.cpp
blob: 3964b12e021ecd9e554cc1ad46d308958e1320b0 (plain) (blame)
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
#include "IdentifierRegistry.hpp"

#include <cassert>

using namespace OpenVic;

HasIdentifier::HasIdentifier(std::string_view new_identifier) : identifier { new_identifier } {
   assert(!identifier.empty());
}

std::ostream& OpenVic::operator<<(std::ostream& stream, HasIdentifier const& obj) {
   return stream << obj.get_identifier();
}

std::ostream& OpenVic::operator<<(std::ostream& stream, HasIdentifier const* obj) {
   return obj != nullptr ? stream << *obj : stream << "<NULL>";
}

HasColour::HasColour(colour_t new_colour, bool cannot_be_null, bool can_have_alpha) : colour(new_colour) {
   assert((!cannot_be_null || colour != NULL_COLOUR) && colour <= (!can_have_alpha ? MAX_COLOUR_RGB : MAX_COLOUR_ARGB));
}

std::string HasColour::colour_to_hex_string() const {
   return OpenVic::colour_to_hex_string(colour);
}

HasIdentifierAndColour::HasIdentifierAndColour(
   std::string_view new_identifier, colour_t new_colour, bool cannot_be_null, bool can_have_alpha
) : HasIdentifier { new_identifier }, HasColour { new_colour, cannot_be_null, can_have_alpha } {}