Skip to content

TBoldElement

Superclass for all elements in Bold

Unit: BoldElements

Declaration

TBoldElement = class(TBoldSubscribableObject)

Hierarchy

  1. TObject
  2. TBoldMemoryManagedObject
  3. TBoldFlaggedObject
  4. TBoldSubscribableObject
  5. TBoldElement
  6. Direct subclasses
  7. TBAValueSetValue
  8. TBoldDomainElement
  9. TBoldMetaElement

Description

TBoldElement is the superclass for all elements in Bold that actually exist, or to be more precise that in themselves represent a value, and object or a piece of meta-information.

It also holds some high-level operations that apply to all Elements such as Assign and Compare.

Properties

Name Summary Notes
AsString The default stringrepresentation of a TBoldElement
BoldType The type of the element read-only
Evaluator Used for evaluating expressions relative to the expression read-only
ModifiedValueHolder GUI locking mechanism of Bold read-only
Mutable If the element can change read-only
StringRepresentation A string representing the value of the element

AsString

property AsString: string;

AsString is the default stringrepresentation of a TBoldElement. It is equivalent to StringRepresentation[brDefault].

BoldType

property BoldType: TBoldElementTypeInfo;

All Bold elements refer to an object representing its type. The fact that everything has type information available in run-time is one of the key features of Bold for Delphi/Bold for C++.

Evaluator

property Evaluator: TBoldEvaluator;

Each TBoldElement has an evaluator that is used for evaluating expressions relative to the expression. The evaluator will actually be part of the runtime information for a TBoldSystem, and the various subclasses to TBoldElement will pick it up in different ways.

ModifiedValueHolder

property ModifiedValueHolder: TObject;

This property is used by the GUI locking mechanism of Bold for Delphi/Bold for C++. It can be set using the methods RegisterModifiedValueHolder and UnRegisterModifiedValueHolder. The locking mechanism is not mandatory, but should be handled by each component and ControlPack.

See Also

Mutable

property Mutable: Boolean;

An element that is mutable is an element that can be changed. Examples of mutable elements are the attributes of an object.

An immutable element can not be changed, ever. The instances of subclasses to TBoldElementTypeInfo are immutable. The metainformation can not change when the application is running. The results of ocl evaluations are also immutable if they are not simple values. You are not allowed to change the result of 'aPerson.firstName + aPerson.lastName'.

One consequence of being immutable is that subscriptions to value changes will be disregarded, another that Bold at its discretion may copy/cache the value for efficiency reasons.

A element may be explicitly made immutable by calling MakeImmutable. This can be done e.g. to enforce security restrictions.

There is no way to make an immutable value mutable again.

StringRepresentation

property StringRepresentation[Representation:TBoldRepresentation]: string;

All Bold elements may represent themselves as strings. The string should in some way reflect the value of the element. The Representation can be used to implement variations, such as brief or verbose.

Methods

Name Summary Notes
Assign Copy the value of one element into another virtual
AssignError Signal an error in an assign operation protected
CloneIfPossible If the element can be cloned, then it will be cloned and the clone will be returned. protected, virtual
CompareError Signal an error in a compare operation protected
CompareTo Compare two elements
CompareToAs Compare two elements virtual
CompareTypeError Signal a CompareType error in a compare operation protected
DefaultSubscribe Place default subscriptions abstract
Destroy Destructor override
EnsureValidString Raise an exception if the string is not valid.
EvaluateAndSubscribeToExpression Evaluate the expression, and place subscriptions to notify when the value of the expression has changed.
EvaluateExpression Evaluate the expression.
EvaluateExpressionAsDirectElement As EvaluateExpression, but sends the resulting value as the return value of function.
EvaluateExpressionAsNewElement As EvaluateExpression, but returns a newly created element.
EvaluateExpressionAsString As EvaluateExpression, but sends the string representation of the expression's result as the return value of function.
GetAsList Gives the element as a list. abstract
GetAsValue Makes itself the value of an indirect element. virtual
GetAsVariant The value of the element as a variant virtual
GetBoldType Get-method for the BoldType property protected, abstract
GetEvaluator Get-method for the Evaluator property protected, virtual
GetStringRepresentation Get-method for the StringRepresentation property protected, virtual
IsEqual True if the element is concidered equal to BoldElement
IsEqualAs True if the element is equal to BoldElement according to the CompareType. virtual
MakeImmutable Sets the element to immutable.
MutableError Signal an error because the element is immutable protected
ObserverMayModify Bold-internal virtual
ObserverMayModifyAsString Bold-internal virtual
PrepareToDestroy Bold-internal
RegisterModifiedValueHolder Sets the ModifiedValueHolder to the observer object.
SetAsVariant Set the value of the element from a variant. virtual
SetStringRepresentation Set-method for the StringRepresentation property. protected, virtual
SubscribeToExpression Places the subscriptions necessary to detect when the result of Expression changes
SubscribeToStringRepresentation Place subscriptions to be notified when the string representation of the element changes. virtual
UnRegisterModifiedValueHolder Remove the observer object as the ModifiedValueHolder
ValidateCharacter Return true if C is a valid character in the string representation Representation of the element. virtual
ValidateString Return true if Value is a valid string representation of the element. virtual

Assign

procedure Assign(Source: TBoldElement); virtual;

The value of the source element will be copied into the element, provided the elements are assignment compatible, i.e. of sufficiently similar types.

AssignError

procedure AssignError(BoldElement: TBoldElement);

This method should only be called by the implementation of Assign in the subclasses of TBoldElement when the type of the source element is not compatible.

CloneIfPossible

function CloneIfPossible: TBoldElement; virtual;

If the element can be cloned, then it will be cloned and the clone will be returned. Otherwise a **nil**-pointer will be returned.

In general, only members can be cloned, but this method could be overriden by a businessobject to clone itself.

CompareError

procedure CompareError(BoldElement: TBoldElement);

This method should only be called by the implementation of CompareToAs in the subclasses of TBoldElement when the types of the elements are not compatible.

CompareTo

function CompareTo(BoldElement: TBoldElement): Integer;

Compare two elements. CompareTo will return 0 if the two elements are equal, -1 if the argument is before self and 1 if self is before the argument. This is equivalent to calling CompareToAs with ctDefault as CompareType.

CompareToAs

function CompareToAs(CompareType: TBoldCompareType; BoldElement: TBoldElement): Integer; virtual;

Compare two elements. CompareToAs will return 0 if the two elements are equal, -1 if the argument is before self and 1 if self is before the argument.

CompareTypeError

procedure CompareTypeError(CompType: TBoldCompareType; BoldElement: TBoldElement);

Called by an implementation of CompareToAs if the elements do not support the CompareType.

DefaultSubscribe

procedure DefaultSubscribe(Subscriber: TBoldSubscriber; RequestedEvent: TBoldEvent = breReEvaluate); virtual; abstract;

Will place the most common subscriptions on the element.

Destroy

destructor Destroy; override; See also Ancestor Method

Destructor

EnsureValidString

procedure EnsureValidString(const Value: string; Representation: TBoldRepresentation);

Will raise an exception if the string Value is not valid for the element, per the ValidateString method.

EvaluateAndSubscribeToExpression

procedure EvaluateAndSubscribeToExpression(const Expression: TBoldExpression; Subscriber: TBoldSubscriber; resultElement: TBoldIndirectElement; Resubscribe: Boolean = false; EvaluateInPS: Boolean = false; const VariableList: TBoldExternalVariableList = nil);

Evaluate the expression, and place subscriptions to notify when the value of the expression has changed. The element is used as root of the expression. resultElement is an indirect element that should be provided by the caller. Its value will be the result of the expression. Subscriber is the subscriber that will receive the subscriptions. If it is **nil** then no subscriptions will be placed. If Resubscribe is true, then all subscriptons will be placed with breResubscribe as RequestedEvent.

If EvaluateInPS is true, then the evaluator will attempt to pass on the expression to the persistence mechanism. If not, the expression will be evaluated in memory. The VariableList can be used to supply variable definitions to the expression.

See Also

EvaluateExpression

procedure EvaluateExpression(const Expression: TBoldExpression; resultElement: TBoldIndirectElement; EvaluateInPS: Boolean = false; const VariableList: TBoldExternalVariableList = nil);

Evaluate the expression. The element is used as root of the expression. resultElement is an indirect element that should be provided by the caller. Its value will be the result of the expression.

If EvaluateInPS is true, then the evaluator will attempt to pass on the expression to the persistence mechanism. If not, the expression will be evaluated in memory. The VariableList can be used to supply variable definitions to the expression.

See Also

EvaluateExpressionAsDirectElement

function EvaluateExpressionAsDirectElement(const Expression: TBoldExpression; const VariableList: TBoldExternalVariableList = nil): TBoldElement;

This method works the same way as EvaluateExpression, with the difference that it returns the resulting element rather than forcing the caller to supply an indirect element to hold the result. This, however, means that the expression must result in an element that is owned (transitively) by a system, i.e. its result must be a Bold object, an attribute or role of a Bold object, an "all instances"-list, a Bold type info or the system itself. Expressions that would not result in an owned element are, for instance, the sum of two attributes, or filtered or sorted lists. Such expressions will return **nil**.

EvaluateExpressionAsNewElement

function EvaluateExpressionAsNewElement(const Expression: TBoldExpression; EvaluateInPS: Boolean = false; const VariableList: TBoldExternalVariableList = nil): TBoldElement;

The result of this function is always an element that must be destroyed after use. If the expression results in an attribute of an object, it will first be cloned before it is returned to you.

EvaluateExpressionAsString

function EvaluateExpressionAsString(const Expression: TBoldExpression; Representation: TBoldRepresentation; EvaluateInPS: Boolean = false; const VariableList: TBoldExternalVariableList = nil): string;

This method works the same way as EvaluateExpression, but sends the string representation of the expression's result as the return value of function.

GetAsList

procedure GetAsList(ResultList: TBoldIndirectElement); virtual; abstract;

Different elements will have different ways of converting themselves to lists. Elements that are already lists, such as TBoldObjectList or TBoldMemberList, will yield themselves as result. Elements that represent more basic entities, such as TBoldObject or TBoldAttribute, will yeild a list with one element. The result will be returned as the Value of the ResultList indirect element.

GetAsValue

procedure GetAsValue(resultElement: TBoldIndirectElement); virtual;

Makes itself the value of an indirect element.

GetAsVariant

function GetAsVariant: Variant; virtual;

This function returns the value of the element as a variant.

GetBoldType

function GetBoldType: TBoldElementTypeInfo; virtual; abstract;

Get-method for the BoldType property

GetEvaluator

function GetEvaluator: TBoldEvaluator; virtual;

Get-method for the Evaluator property

GetStringRepresentation

function GetStringRepresentation(Representation: TBoldRepresentation): string; virtual;

Get-method for the StringRepresentation property. This method can be overridden on TBoldObject subclasses (i.e. the modelled business classes for a project), or TBoldAttribute subclasses, thus providing customized string represenations.

IsEqual

function IsEqual(BoldElement: TBoldElement): Boolean;

The behaviour of this function can be modified by overriding IsEqualAs.

IsEqualAs

function IsEqualAs(CompareType: TBoldCompareType; BoldElement: TBoldElement): Boolean; virtual;

True if the element is equal to BoldElement according to the CompareType. Elements can be compared if they are of sufficiently similar types. This method can be overridden to implement custom criteria for equality.

MakeImmutable

procedure MakeImmutable;

Sets the element to immutable. See Mutable.

MutableError

procedure MutableError(const NewValue: string);

Called by subclasses to TBoldElement if an error occured because the element is immutable.

ObserverMayModify

function ObserverMayModify(Observer: TObject): Boolean; virtual;

Bold-internal

ObserverMayModifyAsString

function ObserverMayModifyAsString(Representation: TBoldRepresentation; observer: TBoldSubscriber): Boolean; virtual;

Bold-internal

PrepareToDestroy

procedure PrepareToDestroy;

This method is intended to be called early in each destructor in the subclasses of TBoldElement. It will call FreePublisher, which in turn will notify all subscribers of the elements' imminent destruction.

Implementation notes
The method is virtual, so subclasses may override it to perform further actions that need to be performed prior to destroying the element. It is not intended to be overridden by developers using Bold.

RegisterModifiedValueHolder

procedure RegisterModifiedValueHolder(observer: TObject);

Sets the ModifiedValueHolder to the observer object.

SetAsVariant

procedure SetAsVariant(const Value: Variant); virtual;

Sets the value of the element from a variant. This method should be overridden by custom attribute classes (i.e. descendents to TBoldAttribute).

SetStringRepresentation

procedure SetStringRepresentation(Representation: TBoldRepresentation; Value: string); virtual;

Set-method for the StringRepresentation property. This method can be overridden in the subclasses to implement customized string representations.

SubscribeToExpression

procedure SubscribeToExpression(const Expression: TBoldExpression; Subscriber: TBoldSubscriber; Resubscribe: Boolean = false; EvaluateInPS: Boolean = false; const VariableList: TBoldExternalVariableList = nil);

Places the subscriptions necessary to detect when the result of Expression changes. See EvaluateAndSubscribeToExpression for details.

SubscribeToStringRepresentation

procedure SubscribeToStringRepresentation(Representation: TBoldRepresentation; Subscriber: TBoldSubscriber; RequestedEvent: TBoldEvent = breReEvaluate); virtual;

Place subscriptions to be notified when the string representation of the element changes. This method should be overridden in subclasses that implement custom string representations.

See Also

UnRegisterModifiedValueHolder

procedure UnRegisterModifiedValueHolder(observer: TObject);

Remove the observer object as the ModifiedValueHolder

ValidateCharacter

function ValidateCharacter(C: AnsiChar; Representation: TBoldRepresentation): Boolean; virtual;

Return true if C is a valid character in the string representation Representation of the element. Override this method to provide quick validation of user input.

ValidateString

function ValidateString(Value: string; Representation: TBoldRepresentation): Boolean; virtual;

Return true if Value is a valid string representation of the element, using the representation Representation. Override this method to provide validation of user input.


Generated from the Bold 4.0 help (Help/BfD.chm) by Tools/chm2mkdocs.py; member lists reflect Bold 4.0, see the source for members added since.