ITemplateManager abstract#
Central interface for managing Blockly templates across all projects.
This interface provides comprehensive template management functionality for PIComposer's visual programming system. Templates are stored in the global IStore and are accessible across all projects within the application.
Key Responsibilities:
- Template creation and deletion
- Template persistence and retrieval
- Template validation and type checking
- Template sharing
- Template version management
Template Types Supported:
- Instance templates (for entity creation)
- Procedure templates (for runtime operations)
- Transformation templates (for data modification)
- Property set templates (for standardized property definitions)
- Quantity set templates (for measurement and quantification)
Templates enable visual programming of complex operations through Blockly's drag-and-drop interface.
Constructors#
ITemplateManager()#
Properties#
hashCode no setter inherited#
The hash code for this object.
A hash code is a single integer which represents the state of the object that affects operator == comparisons.
All objects have hash codes. The default hash code implemented by Object represents only the identity of the object, the same way as the default operator == implementation only considers objects equal if they are identical (see identityHashCode).
If operator == is overridden to use the object state instead, the hash code must also be changed to represent that state, otherwise the object cannot be used in hash based data structures like the default Set and Map implementations.
Hash codes must be the same for objects that are equal to each other according to operator ==. The hash code of an object should only change if the object changes in a way that affects equality. There are no further requirements for the hash codes. They need not be consistent between executions of the same program and there are no distribution guarantees.
Objects that are not equal are allowed to have the same hash code. It is even technically allowed that all instances have the same hash code, but if clashes happen too often, it may reduce the efficiency of hash-based data structures like HashSet or HashMap.
If a subclass overrides hashCode, it should override the operator == operator as well to maintain consistency.
Inherited from Object.
Implementation
external int get hashCode;
runtimeType no setter inherited#
A representation of the runtime type of the object.
Inherited from Object.
Implementation
external Type get runtimeType;
Methods#
createInstanceTemplate()#
Creates an instance template based on a specific target instance.
This method generates a specialized IBlocklyInstanceTemplate that packages the content of the target instance for reuse in other models. The template captures the complete instance definition along with all necessary dependencies to ensure successful deployment in different model contexts.
Eligibility: The instance type that can be packaged is determined by the function isInstanceTemplateType. Currently supported types include:
- Subtypes of IfcProduct (building elements, spatial elements, etc.)
- IfcShapeRepresentation (geometric representations)
- IfcGrid
Package Contents: All templates include essential context information for validation when injecting content into another model:
- Unit assignment information
- Geometric representation context
Type-Specific Inclusions:
- For IfcShapeRepresentation instances: All referenced geometric dependencies are included in the package (representation items, styles, and mapped items)
-
For IfcProduct subtypes: - Complete placement hierarchy (IfcLocalPlacement)
- Referenced IfcShapeRepresentation instances and all their content
- Spatial children related via: - IfcRelVoidsElement (opening relationships)
- IfcRelFillsElement (filling relationships)
Parameters:
-
context: The model context in which the template is created from. This provides the schema definition, and unit system necessary for proper template creation and validation. -
target: The target instance that serves as the basis for the template. The instance must be eligible for templating as determined by isInstanceTemplateType.
Returns an IBlocklyInstanceTemplate instance configured with the target's complete structure and dependencies, ready for visual programming customization and deployment in other models.
Returns a null template if:
- The target instance is not eligible for templating
- The context model is invalid
The created template ensures that all necessary context and dependencies are preserved, enabling reliable instance replication across different models while maintaining geometric and semantic integrity.
Implementation
IBlocklyInstanceTemplate createInstanceTemplate(
IModel context, IInstance target);
createTemplate()#
Creates a new template of the specified type and schema.
Parameters:
schemaEn: The schema enumeration that the template will operate ontypeId: Optional type identifier for entity-specific templatestypeName: Optional type name for entity-specific templates
Returns a new IBlocklyTemplate instance.
Either typeId or typeName must be provided for entity-specific templates.
Implementation
IBlocklyTemplate createTemplate(SupportedSchema schemaEn,
{int? typeId, String? typeName});
deleteTemplate()#
Deletes a template from the database by its handle.
Parameters:
handle: The persistent handle of the template to delete
Returns true if the template was successfully deleted, or false otherwise.
⚠️ Warning: This operation is irreversible and permanently removes the template from the global store.
Implementation
bool deleteTemplate(TemplateInstanceHandle handle);
getDartVMLastError()#
Get the last recorded error of the dart VM This is particularly useful if these is compile error in the scripting engine
Implementation
String getDartVMLastError();
getDartVMStatus()#
Get the dart VM status
Implementation
DartVMStatus getDartVMStatus();
getTemplate()#
Retrieves a template by its persistent handle.
Parameters:
handle: The persistent handle of the template to retrieve
Returns the requested IBlocklyTemplate instance.
Returns a null template if the handle is invalid or doesn't exist.
Implementation
IBlocklyTemplate getTemplate(TemplateInstanceHandle handle);
getTemplateHandles()#
Retrieves persistent handles for all templates in the store.
Returns a list of TemplateInstanceHandle objects for all available templates.
This provides lightweight access to template identifiers without loading the full template content.
Implementation
List<TemplateInstanceHandle> getTemplateHandles();
getTemplates()#
Retrieves all templates from the store.
Returns a list of all IBlocklyTemplate instances available in the store.
⚠️ Performance Note: This method may be expensive for large template collections. Consider using filtered retrieval methods for better performance.
Implementation
List<IBlocklyTemplate> getTemplates();
getTemplatesBySchema()#
Retrieves templates filtered by schema.
Parameters:
schemaEnum: The schema enumeration to filter templates by
Returns a list of IBlocklyTemplate instances for the specified schema.
Implementation
List<IBlocklyTemplate> getTemplatesBySchema(SupportedSchema schemaEnum);
getTemplatesByTag()#
Retrieves templates filtered by tag.
Parameters:
tag: The tag to filter templates by
Returns a list of IBlocklyTemplate instances with the specified tag.
Implementation
List<IBlocklyTemplate> getTemplatesByTag(String tag);
getTemplatesByTagSchema()#
Retrieves templates filtered by both tag and schema.
Parameters:
tag: The tag to filter templates byschemaEnum: The schema enumeration to filter templates by
Returns a list of IBlocklyTemplate instances that match both criteria.
Implementation
List<IBlocklyTemplate> getTemplatesByTagSchema(
String tag, SupportedSchema schemaEnum);
getTemplatesByType()#
Retrieves templates filtered by entity type.
Parameters:
type: The type identifier to filter templates by
Returns a list of IBlocklyTemplate instances of the specified type.
Implementation
List<IBlocklyTemplate> getTemplatesByType(int type);
getTemplatesByTypeSchema()#
Retrieves templates filtered by both type and schema.
Parameters:
type: The type identifier to filter templates byschemaEnum: The schema enumeration to filter templates by
Returns a list of IBlocklyTemplate instances that match both criteria.
Implementation
List<IBlocklyTemplate> getTemplatesByTypeSchema(
int type, SupportedSchema schemaEnum);
importTemplatesFromFile()#
Imports templates from a file.
Parameters:
filePath: The path to the file from which templates will be loaded
Returns a list of IBlocklyTemplate instances loaded from the file and saved to the global store if does not exist in store or version id greater.
Implementation
List<IBlocklyTemplate> importTemplatesFromFile(String filePath);
initialize()#
Initializes the template database system.
Returns true if initialization was successful, or false otherwise.
This method must be called before any template operations can be performed. It prepares the template storage system and loads any default templates.
Implementation
bool initialize();
isInstanceTemplateType()#
Checks if an entity type is eligible for instance template creation.
Parameters:
schemaEn: The schema enumeration to check againsttype: The type identifier to validate
Returns true if the type can be used for instance templates, or false otherwise.
Currently, only the following types are eligible:
- Subtypes of IfcProduct (for building elements)
- IfcShapeRepresentation (for geometric representations)
Implementation
bool isInstanceTemplateType(SupportedSchema schemaEn, int type);
loadTemplatesFromFile()#
Loads templates from a file.
Parameters:
filePath: The path to the file from which templates will be loaded
Returns a list of IBlocklyTemplate instances loaded from the file.
Implementation
List<IBlocklyTemplate> loadTemplatesFromFile(String filePath);
noSuchMethod() inherited#
Invoked when a nonexistent method or property is accessed.
A dynamic member invocation can attempt to call a member which doesn't exist on the receiving object. Example:
dynamic object = 1;
object.add(42); // Statically allowed, run-time error
This invalid code will invoke the noSuchMethod method
of the integer 1 with an Invocation
representing the
.add(42) call and arguments (which then throws).
Classes can override noSuchMethod to provide custom behavior for such invalid dynamic invocations.
A class with a non-default noSuchMethod invocation can also omit implementations for members of its interface. Example:
class MockList<T> implements List<T> {
noSuchMethod(Invocation invocation) {
log(invocation);
super.noSuchMethod(invocation); // Will throw.
}
}
void main() {
MockList().add(42);
}
This code has no compile-time warnings or errors even though
the MockList class has no concrete implementation of
any of the List interface methods.
Calls to List methods are forwarded to noSuchMethod,
so this code will log an invocation similar to
Invocation.method(#add, [42]) and then throw.
If a value is returned from noSuchMethod,
it becomes the result of the original invocation.
If the value is not of a type that can be returned by the original
invocation, a type error occurs at the invocation.
The default behavior is to throw a NoSuchMethodError.
Inherited from Object.
Implementation
@pragma("vm:entry-point")
@pragma("wasm:entry-point")
external dynamic noSuchMethod(Invocation invocation);
saveTemplate()#
Saves a template to the database with optional tagging.
Parameters:
templateInst: The template instance to persisttag: Optional tag for categorization and filtering
Returns true if the template was successfully saved, or false otherwise.
Saved templates become available across all projects in the application.
Implementation
bool saveTemplate(IBlocklyTemplate templateInst, {String? tag});
saveTemplatesToFile()#
Saves a list of templates to a file.
Parameters:
-
templates: The list of IBlocklyTemplate instances to save -
filePath: The path to the file where templates will be saved. File extension should be .pit.
Returns true if the templates were successfully saved, or false otherwise.
Implementation
bool saveTemplatesToFile(List<IBlocklyTemplate> templates, String filePath);
toString() inherited#
A string representation of this object.
Some classes have a default textual representation,
often paired with a static parse function (like int.parse).
These classes will provide the textual representation as
their string representation.
Other classes have no meaningful textual representation
that a program will care about.
Such classes will typically override toString to provide
useful information when inspecting the object,
mainly for debugging or logging.
Inherited from Object.
Implementation
external String toString();
Operators#
operator ==() inherited#
The equality operator.
The default behavior for all Objects is to return true if and
only if this object and other are the same object.
Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:
Total: It must return a boolean for all arguments. It should never throw.
Reflexive: For all objects
o,o == omust be true.-
Symmetric: For all objects
o1ando2,o1 == o2ando2 == o1must either both be true, or both be false. -
Transitive: For all objects
o1,o2, ando3, ifo1 == o2ando2 == o3are true, theno1 == o3must be true.
The method should also be consistent over time, so whether two objects are equal should only change if at least one of the objects was modified.
If a subclass overrides the equality operator, it should override the hashCode method as well to maintain consistency.
Inherited from Object.
Implementation
external bool operator ==(Object other);
