dimval 0.2.0
Modern C++23 header-only library of dimensional values (units, measures, ranges)
Loading...
Searching...
No Matches
interface.hpp File Reference

Abstract interfaces for runtime polymorphic handling of dimensional values. More...

#include <dimval/descriptor.hpp>
#include <memory>
#include <string>
#include <vector>
Include dependency graph for interface.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  dimval::IUnitValue
 Polymorphic interface implemented by every UnitValue<U,T>. More...
 
class  dimval::IMeasureValue
 Polymorphic interface implemented by every MeasureValue<M,T>. More...
 

Typedefs

using dimval::IUnitValueUnique = std::unique_ptr< IUnitValue >
 Owning handles to a polymorphic IUnitValue.
 
using dimval::IUnitValues = std::vector< IUnitValueShared >
 Convenience aliases for collections of polymorphic values.
 
using dimval::IMeasureValueUnique = std::unique_ptr< IMeasureValue >
 Owning handles to a polymorphic IMeasureValue.
 
using dimval::IMeasureValues = std::vector< IMeasureValueShared >
 Convenience aliases for collections of polymorphic values.
 

Detailed Description

Abstract interfaces for runtime polymorphic handling of dimensional values.

IUnitValue and IMeasureValue are pure-virtual base classes implemented by every UnitValue<U,T> / MeasureValue<M,T> template instantiation. They let you store heterogeneous values in std::vector<std::unique_ptr<IUnitValue>> or pass them across an ABI without seeing the concrete unit/measure tags.

The virtual surface is deliberately narrow: only the per-instance state (numeric value, formatted rendering, deep copy) plus the descriptor accessor needed to introspect metadata across the ABI boundary. Per-field metadata (id, symbol, kind, ...) lives as static constexpr accessors on the concrete UnitValue<U,T> / MeasureValue<M,T> templates and is reachable via descriptor() from a polymorphic handle.