Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Model): move up component_id() in Component class #1099

Merged
merged 2 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions include/geode/model/mixin/core/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ namespace geode
return component_type_static();
}

[[nodiscard]] ComponentID component_id() const
{
return { this->component_type_static(), this->id() };
};

template < typename TypedMesh = Mesh >
[[nodiscard]] const TypedMesh& mesh() const
{
Expand Down
5 changes: 0 additions & 5 deletions include/geode/model/mixin/core/block_collection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ namespace geode
return component_type_static();
}

[[nodiscard]] ComponentID component_id() const
{
return { this->component_type_static(), this->id() };
};

public:
BlockCollection( BlockCollectionsKey ) : BlockCollection() {}

Expand Down
2 changes: 2 additions & 0 deletions include/geode/model/mixin/core/component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ namespace geode

[[nodiscard]] virtual ComponentType component_type() const = 0;

[[nodiscard]] ComponentID component_id() const;

protected:
Component();

Expand Down
5 changes: 0 additions & 5 deletions include/geode/model/mixin/core/corner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ namespace geode
return component_type_static();
}

[[nodiscard]] ComponentID component_id() const
{
return { this->component_type_static(), this->id() };
};

[[nodiscard]] const Mesh& mesh() const;

[[nodiscard]] const MeshImpl& mesh_type() const;
Expand Down
5 changes: 0 additions & 5 deletions include/geode/model/mixin/core/corner_collection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ namespace geode
return component_type_static();
}

[[nodiscard]] ComponentID component_id() const
{
return { this->component_type_static(), this->id() };
};

public:
CornerCollection( CornerCollectionsKey ) : CornerCollection() {}

Expand Down
5 changes: 0 additions & 5 deletions include/geode/model/mixin/core/line.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ namespace geode
return component_type_static();
}

[[nodiscard]] ComponentID component_id() const
{
return { this->component_type_static(), this->id() };
};

[[nodiscard]] const Mesh& mesh() const;

[[nodiscard]] const MeshImpl& mesh_type() const;
Expand Down
5 changes: 0 additions & 5 deletions include/geode/model/mixin/core/line_collection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ namespace geode
return component_type_static();
}

[[nodiscard]] ComponentID component_id() const
{
return { this->component_type_static(), this->id() };
};

public:
LineCollection( LineCollectionsKey ) : LineCollection() {}

Expand Down
5 changes: 0 additions & 5 deletions include/geode/model/mixin/core/model_boundary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ namespace geode
return component_type_static();
}

[[nodiscard]] ComponentID component_id() const
{
return { this->component_type_static(), this->id() };
};

public:
ModelBoundary( ModelBoundariesKey ) : ModelBoundary() {}

Expand Down
5 changes: 0 additions & 5 deletions include/geode/model/mixin/core/surface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ namespace geode
return component_type_static();
}

[[nodiscard]] ComponentID component_id() const
{
return { this->component_type_static(), this->id() };
};

template < typename TypedMesh = Mesh >
[[nodiscard]] const TypedMesh& mesh() const
{
Expand Down
5 changes: 0 additions & 5 deletions include/geode/model/mixin/core/surface_collection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ namespace geode
return component_type_static();
}

[[nodiscard]] ComponentID component_id() const
{
return { this->component_type_static(), this->id() };
};

public:
SurfaceCollection( SurfaceCollectionsKey ) : SurfaceCollection() {}

Expand Down
34 changes: 19 additions & 15 deletions src/geode/model/mixin/core/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,14 @@ namespace geode
class Component< dimension >::Impl
{
public:
std::string_view name() const
std::string_view backward_compatible_name() const
{
return name_;
return backward_compatible_name_;
}

void set_name( std::string_view name )
const uuid& backward_compatible_id() const
{
name_ = to_string( name );
}

const uuid& id() const
{
return id_;
return backward_compatible_id_;
}

private:
Expand All @@ -59,14 +54,15 @@ namespace geode
{
archive.ext( *this,
Growable< Archive, Impl >{ { []( Archive& a, Impl& impl ) {
a.text1b( impl.name_, impl.name_.max_size() );
a.object( impl.id_ );
a.text1b( impl.backward_compatible_name_,
impl.backward_compatible_name_.max_size() );
a.object( impl.backward_compatible_id_ );
} } } );
}

private:
std::string name_ = std::string{ "unknown" };
uuid id_;
std::string backward_compatible_name_ = std::string{ "unknown" };
uuid backward_compatible_id_;
};

template < index_t dimension >
Expand All @@ -78,6 +74,12 @@ namespace geode
template < index_t dimension >
Component< dimension >::Component( Component&& ) noexcept = default;

template < index_t dimension >
ComponentID Component< dimension >::component_id() const
{
return { this->component_type(), this->id() };
};

template < index_t dimension >
template < typename Archive >
void Component< dimension >::serialize( Archive& archive )
Expand All @@ -86,8 +88,10 @@ namespace geode
*this, Growable< Archive, Component >{
{ []( Archive& a, Component& component ) {
a.object( component.impl_ );
component.set_id( component.impl_->id() );
component.set_name( component.impl_->name() );
component.set_id(
component.impl_->backward_compatible_id() );
component.set_name(
component.impl_->backward_compatible_name() );
component.impl_.reset();
},
[]( Archive& a, Component& component ) {
Expand Down