Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::components::ReferenceResolutionBudget Class Reference

Bounds document-wide href inheritance traversal for filters, gradients, and patterns. More...

#include "donner/svg/components/ReferenceResolutionBudget.h"

Classes

struct  Limits
 Caller-selected depth and per-kind hop limits. More...
struct  Stats
 Accumulated reservation state for one reference kind. More...

Public Types

enum class  Kind : std::size_t {
  Filter ,
  Gradient ,
  Pattern ,
  Count
}
 Independent reference chains charged against this document budget. More...

Public Member Functions

 ReferenceResolutionBudget (Limits limits)
 Create a budget with caller-selected depth and hop limits.
bool reserve (Kind kind, std::size_t depth)
 Charge a reference hop at the given inheritance depth.
void reset (Kind kind)
 Clear the hop count and rejection state for one reference kind.
const Stats & stats (Kind kind) const
 Return accumulated hop count and rejection state for one reference kind.

Static Public Attributes

static constexpr std::size_t kMaximumReferenceDepth = 64
 Maximum inheritance depth accepted for one reference chain.
static constexpr std::size_t kMaximumHopsPerKind = 64 * 1024
 Maximum reference hops accepted per kind across the document.

Detailed Description

Bounds document-wide href inheritance traversal for filters, gradients, and patterns.


Class Documentation

◆ donner::svg::components::ReferenceResolutionBudget::Limits

struct donner::svg::components::ReferenceResolutionBudget::Limits

Caller-selected depth and per-kind hop limits.

Class Members
size_t maximumHopsPerKind = kMaximumHopsPerKind Maximum aggregate hops charged to each reference kind.
size_t maximumReferenceDepth = kMaximumReferenceDepth Maximum depth of one inheritance chain.

◆ donner::svg::components::ReferenceResolutionBudget::Stats

struct donner::svg::components::ReferenceResolutionBudget::Stats

Accumulated reservation state for one reference kind.

Class Members
size_t hops = 0 Number of successful reference hops charged.
bool rejected = false True after this kind exceeds either configured limit.

Member Enumeration Documentation

◆ Kind

Independent reference chains charged against this document budget.

Enumerator
Filter 

Filter inheritance references.

Gradient 

Gradient inheritance references.

Pattern 

Pattern inheritance references.

Count 

Number of tracked reference kinds; not a reservable kind.

Constructor & Destructor Documentation

◆ ReferenceResolutionBudget()

donner::svg::components::ReferenceResolutionBudget::ReferenceResolutionBudget ( Limits limits)
inlineexplicit

Create a budget with caller-selected depth and hop limits.

Parameters
limitsLimits applied independently to each reference kind.

Member Function Documentation

◆ reserve()

bool donner::svg::components::ReferenceResolutionBudget::reserve ( Kind kind,
std::size_t depth )
inline

Charge a reference hop at the given inheritance depth.

Parameters
kindReference kind being traversed.
depthDepth of this hop in the current inheritance chain.
Returns
False if this kind has already rejected work or either limit is exceeded.

◆ reset()

void donner::svg::components::ReferenceResolutionBudget::reset ( Kind kind)
inline

Clear the hop count and rejection state for one reference kind.

Parameters
kindReference kind to reset.

◆ stats()

const Stats & donner::svg::components::ReferenceResolutionBudget::stats ( Kind kind) const
inline

Return accumulated hop count and rejection state for one reference kind.

Parameters
kindReference kind to inspect.

The documentation for this class was generated from the following file: