SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmmvis::pattern::PatternRegistry Class Reference

#include <patternregistry.h>

Inheritance diagram for openswmmvis::pattern::PatternRegistry:
Collaboration diagram for openswmmvis::pattern::PatternRegistry:

Signals

void providerAdded (openswmmvis::pattern::PatternProvider *provider)
 A provider was created and added to the registry.
 
void providerAboutToBeRemoved (openswmmvis::pattern::PatternProvider *provider)
 A provider is about to be removed. Subscribers must drop refs.
 
void providerRenamed (openswmmvis::pattern::PatternProvider *provider, const QString &prevName, const QString &newName)
 A provider's name changed.
 

Public Member Functions

 PatternRegistry (QObject *parent=nullptr)
 
 ~PatternRegistry () override
 
QVector< PatternProvider * > providers () const
 All providers in insertion order.
 
int providerCount () const noexcept
 
PatternProviderfindByName (const QString &name) const
 Find by exact name (case-insensitive). Returns nullptr if absent.
 
bool hasName (const QString &name) const
 True iff a provider with this name exists (case-insensitive).
 
PatternProvidercreate (const QString &name, PatternType type)
 Create + own a new provider with the given name + type.
 
PatternProviderduplicate (const QString &srcName, const QString &newName)
 Clone an existing provider under a new name. Copies the source provider's type and all factor values. Returns nullptr if either name is invalid or newName already exists.
 
void remove (PatternProvider *p)
 Remove + delete a provider. Safe to call with a stale pointer (no-op if not owned by this registry). When an engine handle is attached the matching pattern is also dropped from the engine via swmm_pattern_remove, cascading to any reference sites.
 
bool rename (PatternProvider *p, const QString &newName)
 Rename a provider. Performs the uniqueness check; returns false (and emits no signal) if newName collides with a different existing provider. Same provider with same name is a no-op success. When an engine handle is attached the rename is mirrored via swmm_pattern_rename so every engine-side reference updates atomically.
 
int loadFromEngine (void *engineHandle)
 Populate the registry from a live SWMM engine handle. Walks swmm_pattern_*, creates one PatternProvider per entry — loading all factors. Pre-existing providers are NOT cleared; conflicts (duplicate name) are skipped silently.
 
int saveToEngine (void *engineHandle)
 Push every provider's factors back to the engine via swmm_pattern_set_factors. New providers (missing from the engine) are added via swmm_pattern_add first (requires the engine to be in BUILDING state).
 
void attachEngine (void *engineHandle)
 Attach an engine handle so subsequent mutations (create / remove / rename / duplicate) are mirrored to the engine via the matching swmm_pattern_* calls. Passing nullptr detaches. Used by SWMMModelLayer::ensurePatternRegistry.
 
void * engineHandle () const noexcept
 The currently-attached engine handle (or nullptr).
 

Constructor & Destructor Documentation

◆ PatternRegistry()

openswmmvis::pattern::PatternRegistry::PatternRegistry ( QObject *  parent = nullptr)
explicit

◆ ~PatternRegistry()

openswmmvis::pattern::PatternRegistry::~PatternRegistry ( )
overridedefault

Member Function Documentation

◆ attachEngine()

void openswmmvis::pattern::PatternRegistry::attachEngine ( void *  engineHandle)
inline

Attach an engine handle so subsequent mutations (create / remove / rename / duplicate) are mirrored to the engine via the matching swmm_pattern_* calls. Passing nullptr detaches. Used by SWMMModelLayer::ensurePatternRegistry.

Here is the call graph for this function:

◆ create()

PatternProvider * openswmmvis::pattern::PatternRegistry::create ( const QString &  name,
PatternType  type 
)

Create + own a new provider with the given name + type.

Returns
the new provider, or nullptr if the name is already in use or the name is empty.

If an engine handle is attached (see attachEngine), the new pattern is also added to the engine via swmm_pattern_add so the two stay in sync from the moment of creation.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ duplicate()

PatternProvider * openswmmvis::pattern::PatternRegistry::duplicate ( const QString &  srcName,
const QString &  newName 
)

Clone an existing provider under a new name. Copies the source provider's type and all factor values. Returns nullptr if either name is invalid or newName already exists.

Here is the call graph for this function:

◆ engineHandle()

void * openswmmvis::pattern::PatternRegistry::engineHandle ( ) const
inlinenoexcept

The currently-attached engine handle (or nullptr).

Here is the caller graph for this function:

◆ findByName()

PatternProvider * openswmmvis::pattern::PatternRegistry::findByName ( const QString &  name) const

Find by exact name (case-insensitive). Returns nullptr if absent.

Here is the caller graph for this function:

◆ hasName()

bool openswmmvis::pattern::PatternRegistry::hasName ( const QString &  name) const
inline

True iff a provider with this name exists (case-insensitive).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadFromEngine()

int openswmmvis::pattern::PatternRegistry::loadFromEngine ( void *  engineHandle)

Populate the registry from a live SWMM engine handle. Walks swmm_pattern_*, creates one PatternProvider per entry — loading all factors. Pre-existing providers are NOT cleared; conflicts (duplicate name) are skipped silently.

Parameters
engineHandleOpaque pointer to SWMM_Engine. Passed as void* so this header stays free of the engine C header.
Returns
the number of providers added.
Here is the call graph for this function:

◆ providerAboutToBeRemoved

void openswmmvis::pattern::PatternRegistry::providerAboutToBeRemoved ( openswmmvis::pattern::PatternProvider provider)
signal

A provider is about to be removed. Subscribers must drop refs.

Here is the caller graph for this function:

◆ providerAdded

void openswmmvis::pattern::PatternRegistry::providerAdded ( openswmmvis::pattern::PatternProvider provider)
signal

A provider was created and added to the registry.

Here is the caller graph for this function:

◆ providerCount()

int openswmmvis::pattern::PatternRegistry::providerCount ( ) const
inlinenoexcept

◆ providerRenamed

void openswmmvis::pattern::PatternRegistry::providerRenamed ( openswmmvis::pattern::PatternProvider provider,
const QString &  prevName,
const QString &  newName 
)
signal

A provider's name changed.

Here is the caller graph for this function:

◆ providers()

QVector< PatternProvider * > openswmmvis::pattern::PatternRegistry::providers ( ) const
inline

All providers in insertion order.

◆ remove()

void openswmmvis::pattern::PatternRegistry::remove ( PatternProvider p)

Remove + delete a provider. Safe to call with a stale pointer (no-op if not owned by this registry). When an engine handle is attached the matching pattern is also dropped from the engine via swmm_pattern_remove, cascading to any reference sites.

Here is the call graph for this function:

◆ rename()

bool openswmmvis::pattern::PatternRegistry::rename ( PatternProvider p,
const QString &  newName 
)

Rename a provider. Performs the uniqueness check; returns false (and emits no signal) if newName collides with a different existing provider. Same provider with same name is a no-op success. When an engine handle is attached the rename is mirrored via swmm_pattern_rename so every engine-side reference updates atomically.

Here is the call graph for this function:

◆ saveToEngine()

int openswmmvis::pattern::PatternRegistry::saveToEngine ( void *  engineHandle)

Push every provider's factors back to the engine via swmm_pattern_set_factors. New providers (missing from the engine) are added via swmm_pattern_add first (requires the engine to be in BUILDING state).

Returns
the number of patterns written.
Here is the call graph for this function:

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