MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / addColorSpace

Method addColorSpace

src/OpenColorIO/Config.cpp:2577–2648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2575}
2576
2577void Config::addColorSpace(const ConstColorSpaceRcPtr & original)
2578{
2579 const std::string name(original->getName());
2580 if (name.empty())
2581 {
2582 throw Exception("Color space must have a non-empty name.");
2583 }
2584
2585 // Check this is not an existing role or named transform.
2586 if (hasRole(name.c_str()))
2587 {
2588 std::ostringstream os;
2589 os << "Cannot add '" << name << "' color space, there is already a role with this "
2590 "name.";
2591 throw Exception(os.str().c_str());
2592 }
2593 auto nt = getNamedTransform(name.c_str());
2594 if (nt)
2595 {
2596 std::ostringstream os;
2597 os << "Cannot add '" << name << "' color space, there is already a named transform using "
2598 "this name as a name or as an alias: '" << nt->getName() << "'.";
2599 throw Exception(os.str().c_str());
2600 }
2601
2602 if (getMajorVersion() >= 2 && ContainsContextVariableToken(name))
2603 {
2604 std::ostringstream oss;
2605 oss << "A color space name '" << name
2606 << "' cannot contain a context variable reserved token i.e. % or $.";
2607
2608 throw Exception(oss.str().c_str());
2609 }
2610
2611 const size_t numAliases = original->getNumAliases();
2612 for (size_t aidx = 0; aidx < numAliases; ++aidx)
2613 {
2614 const char * alias = original->getAlias(aidx);
2615
2616 if (hasRole(alias))
2617 {
2618 std::ostringstream os;
2619 os << "Cannot add '" << name << "' color space, it has an alias '" << alias
2620 << "' and there is already a role with this name.";
2621 throw Exception(os.str().c_str());
2622 }
2623 auto nt = getNamedTransform(alias);
2624 if (nt)
2625 {
2626 std::ostringstream os;
2627 os << "Cannot add '" << name << "' color space, it has an alias '" << alias
2628 << "' and there is already a named transform using this name as a name or as "
2629 "an alias: '" << nt->getName() << "'.";
2630 throw Exception(os.str().c_str());
2631 }
2632 if (ContainsContextVariableToken(alias))
2633 {
2634 std::ostringstream os;

Callers 15

mainFunction · 0.45
mainFunction · 0.45
_add_itemMethod · 0.45
_new_itemMethod · 0.45
_set_valueMethod · 0.45
_get_placeholder_viewMethod · 0.45
_insert_ruleMethod · 0.45
loadFunction · 0.45
instantiateDisplayMethod · 0.45
getColorSpacesMethod · 0.45

Calls 8

resetCacheIDsMethod · 0.80
getImplFunction · 0.50
getNameMethod · 0.45
emptyMethod · 0.45
getNumAliasesMethod · 0.45
getAliasMethod · 0.45

Tested by 15

test_using_rulesMethod · 0.36
test_copyMethod · 0.36
test_canonical_nameMethod · 0.36
test_virtual_displayMethod · 0.36
test_copyMethod · 0.36
test_color_spacesMethod · 0.36
test_encodingsMethod · 0.36
OCIO_ADD_TESTFunction · 0.36
OCIO_ADD_TESTFunction · 0.36
OCIO_ADD_TESTFunction · 0.36