/packages/fcl-sdo/src/base/sdo_dataobject.pas
https://github.com/slibre/freepascal · Pascal · 4199 lines · 3467 code · 408 blank · 324 comment · 324 complexity · 2b95a80fc937a285b144f14dee5a4de0 MD5 · raw file
Large files are truncated click here to view the full file
- {
- This file is part of the Free Pascal Class Library SDO Implementation
- Copyright (c) 2012 by Inoussa OUEDRAOGO
- Free Pascal development team
- This unit implements the basic SDO objects
- See the file COPYING.FPC, included in this distribution,
- for details about the copyright.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- **********************************************************************}
- {$INCLUDE sdo_global.inc}
- unit sdo_dataobject;
- interface
- uses
- SysUtils, Classes, Contnrs,
- sdo_types, sdo, sdo_type, sdo_changesummary, sdo_xpath_helper, sdo_linked_list,
- sdo_field_imp;
- type
- IDataObjectObserver = interface
- ['{EF23F339-EF10-4312-B202-43AA5C743841}']
- procedure NotifyDeletion(
- const ADataObject : ISDODataObject;
- const AProperty : ISDOProperty
- );
- end;
- ISDODataObjectEx = interface(ISDODataObject)
- ['{2EA33304-D190-425F-A952-685619896AB2}']
- //Return TRUE if this instance is an instance or a derived class
- function IsInstanceOf(const AType : ISDOType) : Boolean;
- function IsAncestorOf(const AObject : ISDODataObject) : Boolean;
- procedure setContainer(
- const AContainer : ISDODataObject;
- const AContainerProperty : ISDOProperty
- );
- procedure AddReference(
- const AReferencer : ISDODataObject;
- const AReferenceProperty : ISDOProperty
- );
- procedure RemoveReference(
- const AReferencer : ISDODataObject;
- const AReferenceProperty : ISDOProperty
- );
- procedure NotifyContainedObjectsForDeletion(const ACallFromParent : Boolean);// logical deletion
- // for open Type support
- procedure addProperty(
- const APropName : string;
- const APropType : ISDOType;
- const AFlags : TPropertyFlags
- );
- end;
- TObserverInfo = class
- private
- FDataObject : Pointer;
- FRefProperty : Pointer;
- public
- constructor Create(const ADataObject : ISDODataObject; const ARefProperty : ISDOProperty);
- function GetDataObject() : ISDODataObject;{$IFDEF USE_INLINE}inline;{$ENDIF}
- function GetRefProperty() : ISDOProperty;{$IFDEF USE_INLINE}inline;{$ENDIF}
- end;
- TDataObjectObserverList = class
- private
- FList : TObjectList;
- public
- constructor Create();
- destructor Destroy();override;
- procedure Add(const ADataObject : ISDODataObject; const ARefProperty : ISDOProperty);{$IFDEF USE_INLINE}inline;{$ENDIF}
- function IndexOf(const ADataObject : ISDODataObject; const ARefProperty : ISDOProperty) : PtrInt;
- function Find(const ADataObject : ISDODataObject; const ARefProperty : ISDOProperty) : TObserverInfo;{$IFDEF USE_INLINE}inline;{$ENDIF}
- function GetCount() : PtrInt;{$IFDEF USE_INLINE}inline;{$ENDIF}
- function GetItem(const AIndex : PtrInt) : TObserverInfo;{$IFDEF USE_INLINE}inline;{$ENDIF}
- function Extract(const AIndex : PtrInt) : TObserverInfo;{$IFDEF USE_INLINE}inline;{$ENDIF}
- procedure Delete(const AIndex : PtrInt);{$IFDEF USE_INLINE}inline;{$ENDIF}
- end;
- TSDOBaseDataObjectClass = class of TSDOBaseDataObject;
- TSDOBaseDataObject = class(
- TInterfacedObject,
- IInterface,
- ISDODataObject,
- ISDODataObjectEx,
- IDataObjectObserver
- )
- private
- FDestroying : Boolean;
- FType : ISDOObjectType;
- FContainer : Pointer;
- FContainerProperty : Pointer;
- FBuffer : TSDOFieldBuffer;
- FBufferLength : PtrUInt;
- FChangeSummary : Pointer;//ISDOChangeSummaryEx;
- FReferenceLinkList : TDataObjectObserverList;
- private
- FXPathExpression : TXPathExpression;
- FXPathProcessor : TXPathProcessor;
- protected
- function _Release: LongInt; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
- procedure PrepareDataBuffer();
- procedure FreeBuffer();
- function parsePropertyPath(const APath : string) : TXPathExecContext;
- function IsOwnerOf(const AProp : ISDOProperty) : Boolean;virtual;//{$IFDEF USE_INLINE}inline;{$ENDIF}
- function CreateList(const AProperty : ISDOProperty) : ISDODataObjectList;{$IFDEF USE_INLINE}inline;{$ENDIF}
- procedure InitializeDefaultValues();
- protected
- procedure RecordChange(const AProperty : ISDOProperty);{$IFDEF USE_INLINE}inline;{$ENDIF}
- procedure NotifyReferencersForDeletion();
- protected
- // ISDODataObjectEx
- function IsInstanceOf(const AType : ISDOType) : Boolean;
- function IsAncestorOf(const AObject : ISDODataObject) : Boolean;
- procedure setContainer(
- const AContainer : ISDODataObject;
- const AContainerProperty : ISDOProperty
- );
- //ISDODataObject
- function getPropertyIndex(const AProperty : ISDOProperty) : PtrInt;
- function getInstanceProperties() : ISDOPropertyList;virtual;
- function getProperty(const AIndex : PtrUInt) : ISDOProperty;overload;
- function getProperty(const AProp : string) : ISDOProperty;overload;
- function getContainer() : ISDODataObject;
- function getContainmentProperty() : ISDOProperty;
- function getType() : ISDOType;
- function getTypeEnum() : TSDOTypeKind;
- function getList(const APath : string) : ISDODataObjectList; overload;
- function getList(const APropertyIndex : PtrUInt) : ISDODataObjectList; overload;
- function getList(const AProperty : ISDOProperty) : ISDODataObjectList; overload;
- function getDataObject(const APath : string) : ISDODataObject; overload;
- function getDataObject(const APropertyIndex : PtrUInt) : ISDODataObject; overload;
- function getDataObject(const AProperty : ISDOProperty) : ISDODataObject; overload;
- procedure setDataObject(const APath : string; AValue : ISDODataObject); overload; virtual;
- procedure setDataObject(const APropertyIndex : PtrUInt; AValue : ISDODataObject); overload;
- procedure setDataObject(const AProperty : ISDOProperty; AValue : ISDODataObject); overload;
- function getBoolean(const APath : string) : TSDOBoolean; overload;
- function getBoolean(const APropertyIndex : PtrUInt) : TSDOBoolean; overload;
- function getBoolean(const AProperty : ISDOProperty) : TSDOBoolean; overload;
- procedure setBoolean(const APath : string; const AValue : TSDOBoolean); overload; virtual;
- procedure setBoolean(const APropertyIndex : PtrUInt; const AValue : TSDOBoolean); overload;
- procedure setBoolean(const AProperty : ISDOProperty; const AValue : TSDOBoolean); overload;
- function getByte(const APath : string) : TSDOByte;overload;
- function getByte(const APropertyIndex : PtrUInt) : TSDOByte;overload;
- function getByte(const AProperty : ISDOProperty) : TSDOByte;overload;
- procedure setByte(const APath : string; const AValue : TSDOByte);overload; virtual;
- procedure setByte(const APropertyIndex : PtrUInt; const AValue : TSDOByte);overload;
- procedure setByte(const AProperty : ISDOProperty; const AValue : TSDOByte);overload;
- {$IFDEF HAS_SDO_CHAR}
- function getCharacter(const APath : string) : TSDOChar;overload;
- function getCharacter(const APropertyIndex : PtrUInt) : TSDOChar;overload;
- function getCharacter(const AProperty : ISDOProperty) : TSDOChar;overload;
- procedure setCharacter(const APath : string; const AValue : TSDOChar);overload; virtual;
- procedure setCharacter(const APropertyIndex : PtrUInt; const AValue : TSDOChar);overload;
- procedure setCharacter(const AProperty : ISDOProperty; const AValue : TSDOChar);overload;
- {$ENDIF HAS_SDO_CHAR}
- {$IFDEF HAS_SDO_BYTES}
- function getBytes(const APath : string) : TSDOBytes;overload;
- function getBytes(const APropertyIndex : PtrUInt) : TSDOBytes;overload;
- function getBytes(const AProperty : ISDOProperty) : TSDOBytes;overload;
- procedure setBytes(const APath : string; AValue : TSDOBytes);overload; virtual;
- procedure setBytes(const APropertyIndex : PtrUInt; AValue : TSDOBytes);overload;
- procedure setBytes(const AProperty : ISDOProperty; AValue : TSDOBytes);overload;
- {$ENDIF HAS_SDO_BYTES}
- {$IFDEF HAS_SDO_CURRENCY}
- function getCurrency(const APath : string) : TSDOCurrency;overload;
- function getCurrency(const APropertyIndex : PtrUInt) : TSDOCurrency;overload;
- function getCurrency(const AProperty : ISDOProperty) : TSDOCurrency;overload;
- procedure setCurrency(const APath : string; const AValue : TSDOCurrency);overload; virtual;
- procedure setCurrency(const APropertyIndex : PtrUInt; const AValue : TSDOCurrency);overload;
- procedure setCurrency(const AProperty : ISDOProperty; const AValue : TSDOCurrency);overload;
- {$ENDIF HAS_SDO_CURRENCY}
- function getString(const APath : string) : TSDOString;overload;
- function getString(const APropertyIndex : PtrUInt) : TSDOString;overload;
- function getString(const AProperty : ISDOProperty) : TSDOString;overload;
- procedure setString(const APath : string; const AValue : TSDOString);overload;virtual;
- procedure setString(const APropertyIndex : PtrUInt; const AValue : TSDOString);overload;
- procedure setString(const AProperty : ISDOProperty; const AValue : TSDOString);overload;
- function getDate(const APath : string) : TSDODate;overload;
- function getDate(const APropertyIndex : PtrUInt) : TSDODate;overload;
- function getDate(const AProperty : ISDOProperty) : TSDODate;overload;
- procedure setDate(const APath : string; const AValue : TSDODate);overload;virtual;
- procedure setDate(const APropertyIndex : PtrUInt; const AValue : TSDODate);overload;
- procedure setDate(const AProperty : ISDOProperty; const AValue : TSDODate);overload;
- {$IFDEF HAS_SDO_DOUBLE}
- function getDouble(const APath : string) : TSDODouble;overload;
- function getDouble(const APropertyIndex : PtrUInt) : TSDODouble;overload;
- function getDouble(const AProperty : ISDOProperty) : TSDODouble;overload;
- procedure setDouble(const APath : string; const AValue : TSDODouble);overload; virtual;
- procedure setDouble(const APropertyIndex : PtrUInt; const AValue : TSDODouble);overload;
- procedure setDouble(const AProperty : ISDOProperty; const AValue : TSDODouble);overload;
- {$ENDIF HAS_SDO_DOUBLE}
- {$IFDEF HAS_SDO_FLOAT}
- function getFloat(const APath : string) : TSDOFloat;overload;
- function getFloat(const APropertyIndex : PtrUInt) : TSDOFloat;overload;
- function getFloat(const AProperty : ISDOProperty) : TSDOFloat;overload;
- procedure setFloat(const APath : string; const AValue : TSDOFloat);overload; virtual;
- procedure setFloat(const APropertyIndex : PtrUInt; const AValue : TSDOFloat);overload;
- procedure setFloat(const AProperty : ISDOProperty; const AValue : TSDOFloat);overload;
- {$ENDIF HAS_SDO_FLOAT}
- function getInteger(const APath : string) : TSDOInteger;overload;
- function getInteger(const APropertyIndex : PtrUInt) : TSDOInteger;overload;
- function getInteger(const AProperty : ISDOProperty) : TSDOInteger;overload;
- procedure setInteger(const APath : string; const AValue : TSDOInteger);overload;virtual;
- procedure setInteger(const APropertyIndex : PtrUInt; const AValue : TSDOInteger);overload;
- procedure setInteger(const AProperty : ISDOProperty; const AValue : TSDOInteger);overload;
- {$IFDEF HAS_SDO_LONG}
- function getLong(const APath : string) : TSDOLong;overload;
- function getLong(const APropertyIndex : PtrUInt) : TSDOLong;overload;
- function getLong(const AProperty : ISDOProperty) : TSDOLong;overload;
- procedure setLong(const APath : string; const AValue : TSDOLong);overload; virtual;
- procedure setLong(const APropertyIndex : PtrUInt; const AValue : TSDOLong);overload;
- procedure setLong(const AProperty : ISDOProperty; const AValue : TSDOLong);overload;
- {$ENDIF HAS_SDO_LONG}
- {$IFDEF HAS_SDO_SHORT}
- function getShort(const APath : string) : TSDOShort;overload;
- function getShort(const APropertyIndex : PtrUInt) : TSDOShort;overload;
- function getShort(const AProperty : ISDOProperty) : TSDOShort;overload;
- procedure setShort(const APath : string; const AValue : TSDOShort);overload; virtual;
- procedure setShort(const APropertyIndex : PtrUInt; const AValue : TSDOShort);overload;
- procedure setShort(const AProperty : ISDOProperty; const AValue : TSDOShort);overload;
- {$ENDIF HAS_SDO_SHORT}
- function getVariant(const APath : string) : TSDOVariant;overload;
- function getVariant(const APropertyIndex : PtrUInt) : TSDOVariant;overload;
- function getVariant(const AProperty : ISDOProperty) : TSDOVariant;overload;
- procedure setVariant(const APath : string; const AValue : TSDOVariant);overload;
- procedure setVariant(const APropertyIndex : PtrUInt; const AValue : TSDOVariant);overload;
- procedure setVariant(const AProperty : ISDOProperty; const AValue : TSDOVariant);overload;
- procedure setNull(const APath : string);overload;
- procedure setNull(const APropertyIndex : PtrUInt);overload;
- procedure setNull(const AProperty : ISDOProperty);overload;
- function isNull(const APath : string) : Boolean;overload;
- function isNull(const APropertyIndex : PtrUInt) : Boolean;overload;
- function isNull(const AProperty : ISDOProperty) : Boolean;overload;
- function isSet(const APath : string) : Boolean;overload;
- function isSet(const APropertyIndex : PtrUInt) : Boolean;overload;
- function isSet(const AProperty : ISDOProperty) : Boolean;overload;
- procedure unset(const APath : string);overload;
- procedure unset(const APropertyIndex : PtrUInt);overload;
- procedure unset(const AProperty : ISDOProperty);overload;
- function createDataObject(const APath : string) : ISDODataObject; overload;
- function createDataObject(const APropertyIndex : PtrUInt) : ISDODataObject; overload;
- function createDataObject(const AProperty : ISDOProperty) : ISDODataObject; overload;
- function getChangeSummary() : ISDOChangeSummary;overload;
- {function getChangeSummary(const APath : string) : ISDOChangeSummary;overload;
- function getChangeSummary(const APropIndex : PtrUInt) : ISDOChangeSummary;overload;
- function getChangeSummary(const AProp : ISDOProperty ) : ISDOChangeSummary;overload;
- }
- procedure clear();
- // IDataObjectObserver implementation
- procedure NotifyDeletion(
- const ADataObject : ISDODataObject;
- const AProperty : ISDOProperty
- );
- procedure AddReference(
- const AReferencer : ISDODataObject;
- const AReferenceProperty : ISDOProperty
- );
- procedure RemoveReference(
- const AReferencer : ISDODataObject;
- const AReferenceProperty : ISDOProperty
- );
- procedure NotifyContainedObjectsForDeletion(const ACallFromParent : Boolean);// logical deletion
- // for open Type support
- procedure addProperty(
- const APropName : string;
- const APropType : ISDOType;
- const AFlags : TPropertyFlags
- );
- public
- constructor Create(
- const AType : ISDOTypeEx;
- const AContainer : ISDODataObject;
- const AContainerProperty : ISDOProperty
- );virtual;
- destructor Destroy();override;
- end;
- TSDODataObject = class(TSDOBaseDataObject, IInterface, ISDODataObject)
- end;
- TSDOOpenedDataObject = class(
- TSDOBaseDataObject,
- IInterface,
- ISDODataObject,
- ISDODataObjectEx
- )
- private
- FInstanceProperties : ISDOPropertyListEx;
- protected
- function IsOwnerOf(const AProp : ISDOProperty) : Boolean; override;
- function getInstanceProperties() : ISDOPropertyList;override;
- procedure setBoolean(const APath : string; const AValue : TSDOBoolean); overload; override;
- procedure setByte(const APath : string; const AValue : TSDOByte); overload; override;
- {$IFDEF HAS_SDO_BYTES}
- procedure setBytes(const APath : string; AValue : TSDOBytes); overload; override;
- {$ENDIF HAS_SDO_BYTES}
- {$IFDEF HAS_SDO_CHAR}
- procedure setCharacter(const APath : string; const AValue : TSDOChar); overload; override;
- {$ENDIF HAS_SDO_CHAR}
- {$IFDEF HAS_SDO_CURRENCY}
- procedure setCurrency(const APath : string; const AValue : Currency); overload; override;
- {$ENDIF HAS_SDO_CURRENCY}
- procedure setDate(const APath : string; const AValue : TSDODate);overload;override;
- {$IFDEF HAS_SDO_DOUBLE}
- procedure setDouble(const APath : string; const AValue : TSDODouble); overload; override;
- {$ENDIF HAS_SDO_DOUBLE}
- {$IFDEF HAS_SDO_FLOAT}
- procedure setFloat(const APath : string; const AValue : TSDOFloat); overload; override;
- {$ENDIF HAS_SDO_FLOAT}
- procedure setInteger(const APath : string; const AValue : TSDOInteger);overload;override;
- {$IFDEF HAS_SDO_LONG}
- procedure setLong(const APath : string; const AValue : TSDOLong); overload; override;
- {$ENDIF HAS_SDO_LONG}
- {$IFDEF HAS_SDO_SHORT}
- procedure setShort(const APath : string; const AValue : TSDOShort); overload; override;
- {$ENDIF HAS_SDO_SHORT}
- procedure setString(const APath : string; const AValue : TSDOString);overload;override;
- procedure setDataObject(const APath : string; AValue : ISDODataObject); overload; override;
- // for open Type support
- procedure addProperty(
- const APropName : string;
- const APropType : ISDOType;
- const AFlags : TPropertyFlags
- );
- public
- constructor Create(
- const AType : ISDOTypeEx;
- const AContainer : ISDODataObject;
- const AContainerProperty : ISDOProperty
- );override;
- end;
- TSDODataObjectList = class(TInterfacedObject,IInterface,ISDODataObjectList)
- private
- FItemType : ISDOType;
- FData : TDoubleLinkedList;
- FCursor : ILinkedListCursor;
- FField : ISDOField;
- private
- procedure Clear();
- procedure InternalDelete(const AData : PLinkedNode);{$IFDEF USE_INLINE}inline;{$ENDIF}
- function InternalAppend() : PLinkedNode;{$IFDEF USE_INLINE}inline;{$ENDIF}
- procedure CheckCursorPosition();{$IFDEF USE_INLINE}inline;{$ENDIF}
- procedure MoveTo(const AIndex : PtrInt);{$IFDEF USE_INLINE}inline;{$ENDIF}
- protected
- function getItemType() : ISDOType;{$IFDEF USE_INLINE}inline;{$ENDIF}
- function size() : PtrInt;
- function getCursor() : ILinkedListCursor;
- {These operations use the cursor location}
- function getBoolean() : TSDOBoolean;overload;
- function getByte() : TSDOByte;overload;
- {$IFDEF HAS_SDO_BYTES}
- function getBytes() : TSDOBytes;overload;
- {$ENDIF HAS_SDO_BYTES}
- {$IFDEF HAS_SDO_CHAR}
- function getCharacter() : TSDOChar;overload;
- {$ENDIF HAS_SDO_CHAR}
- {$IFDEF HAS_SDO_CURRENCY}
- function getCurrency() : TSDOCurrency;overload;
- {$ENDIF HAS_SDO_CURRENCY}
- function getDate() : TSDODate;overload;
- {$IFDEF HAS_SDO_DOUBLE}
- function getDouble() : TSDODouble;overload;
- {$ENDIF HAS_SDO_DOUBLE}
- {$IFDEF HAS_SDO_FLOAT}
- function getFloat() : TSDOFloat;overload;
- {$ENDIF HAS_SDO_FLOAT}
- function getInteger() : TSDOInteger;overload;
- {$IFDEF HAS_SDO_LONG}
- function getLong() : TSDOLong;overload;
- {$ENDIF HAS_SDO_LONG}
- {$IFDEF HAS_SDO_SHORT}
- function getShort() : TSDOShort;overload;
- {$ENDIF HAS_SDO_SHORT}
- function getString() : TSDOString;overload;
- function getDataObject() : ISDODataObject;overload;
- function getVariant() : TSDOVariant;overload;
- procedure setBoolean(const AValue : TSDOBoolean);overload;
- procedure setByte(const AValue : TSDOByte);overload;
- {$IFDEF HAS_SDO_BYTES}
- procedure setBytes(AValue : TSDOBytes);overload;
- {$ENDIF HAS_SDO_BYTES}
- {$IFDEF HAS_SDO_CHAR}
- procedure setCharacter(const AValue : TSDOChar);overload;
- {$ENDIF HAS_SDO_CHAR}
- {$IFDEF HAS_SDO_CURRENCY}
- procedure setCurrency(const AValue : TSDOCurrency);overload;
- {$ENDIF HAS_SDO_CURRENCY}
- procedure setDate(const AValue : TSDODate);overload;
- {$IFDEF HAS_SDO_DOUBLE}
- procedure setDouble(const AValue : TSDODouble);overload;
- {$ENDIF HAS_SDO_DOUBLE}
- {$IFDEF HAS_SDO_FLOAT}
- procedure setFloat(const AValue : TSDOFloat);overload;
- {$ENDIF HAS_SDO_FLOAT}
- procedure setInteger(const AValue : TSDOInteger);overload;
- {$IFDEF HAS_SDO_LONG}
- procedure setLong(const AValue : TSDOLong);overload;
- {$ENDIF HAS_SDO_LONG}
- {$IFDEF HAS_SDO_SHORT}
- procedure setShort(const AValue : TSDOShort);overload;
- {$ENDIF HAS_SDO_SHORT}
- procedure setString(const AValue : TSDOString);overload;
- procedure setDataObject(AValue : ISDODataObject);overload;
- procedure setVariant(const AValue : TSDOVariant);overload;
- function getBoolean(const AIndex : PtrInt) : TSDOBoolean;overload;
- function getByte(const AIndex : PtrInt) : TSDOByte;overload;
- {$IFDEF HAS_SDO_BYTES}
- function getBytes(const AIndex : PtrInt) : TSDOBytes;overload;
- {$ENDIF HAS_SDO_BYTES}
- {$IFDEF HAS_SDO_CHAR}
- function getCharacter(const AIndex : PtrInt) : TSDOChar;overload;
- {$ENDIF HAS_SDO_CHAR}
- {$IFDEF HAS_SDO_CURRENCY}
- function getCurrency(const AIndex : PtrInt) : TSDOCurrency;overload;
- {$ENDIF HAS_SDO_CURRENCY}
- function getDate(const AIndex : PtrInt) : TSDODate;overload;
- {$IFDEF HAS_SDO_DOUBLE}
- function getDouble(const AIndex : PtrInt) : TSDODouble;overload;
- {$ENDIF HAS_SDO_DOUBLE}
- {$IFDEF HAS_SDO_FLOAT}
- function getFloat(const AIndex : PtrInt) : TSDOFloat;overload;
- {$ENDIF HAS_SDO_FLOAT}
- function getInteger(const AIndex : PtrInt) : TSDOInteger;overload;
- {$IFDEF HAS_SDO_LONG}
- function getLong(const AIndex : PtrInt) : TSDOLong;overload;
- {$ENDIF HAS_SDO_LONG}
- {$IFDEF HAS_SDO_SHORT}
- function getShort(const AIndex : PtrInt) : TSDOShort;overload;
- {$ENDIF HAS_SDO_SHORT}
- function getString(const AIndex : PtrInt) : TSDOString;overload;
- function getDataObject(const AIndex : PtrInt) : ISDODataObject;overload;
- function getVariant(const AIndex : PtrInt) : TSDOVariant;overload;
- procedure setBoolean(const AIndex : PtrInt; const AValue : TSDOBoolean);overload;
- procedure setByte(const AIndex : PtrInt; const AValue : TSDOByte);overload;
- {$IFDEF HAS_SDO_BYTES}
- procedure setBytes(const AIndex : PtrInt; AValue : TSDOBytes);overload;
- {$ENDIF HAS_SDO_BYTES}
- {$IFDEF HAS_SDO_CHAR}
- procedure setCharacter(const AIndex : PtrInt; const AValue : TSDOChar);overload;
- {$ENDIF HAS_SDO_CHAR}
- {$IFDEF HAS_SDO_CURRENCY}
- procedure setCurrency(const AIndex : PtrInt; const AValue : TSDOCurrency);overload;
- {$ENDIF HAS_SDO_CURRENCY}
- procedure setDate(const AIndex : PtrInt; const AValue : TSDODate);overload;
- {$IFDEF HAS_SDO_DOUBLE}
- procedure setDouble(const AIndex : PtrInt; const AValue : TSDODouble);overload;
- {$ENDIF HAS_SDO_DOUBLE}
- {$IFDEF HAS_SDO_FLOAT}
- procedure setFloat(const AIndex : PtrInt; const AValue : TSDOFloat);overload;
- {$ENDIF HAS_SDO_FLOAT}
- procedure setInteger(const AIndex : PtrInt; const AValue : TSDOInteger);overload;
- {$IFDEF HAS_SDO_LONG}
- procedure setLong(const AIndex : PtrInt; const AValue : TSDOLong);overload;
- {$ENDIF HAS_SDO_LONG}
- {$IFDEF HAS_SDO_SHORT}
- procedure setShort(const AIndex : PtrInt; const AValue : TSDOShort);overload;
- {$ENDIF HAS_SDO_SHORT}
- procedure setString(const AIndex : PtrInt; const AValue : TSDOString);overload;
- procedure setVariant(const AIndex : PtrInt; const AValue : TSDOVariant);overload;
- procedure setDataObject(const AIndex : PtrInt; AValue : ISDODataObject);overload;
- procedure insert(const AIndex : PtrInt; const AValue : TSDOBoolean);overload;
- procedure insert(const AIndex : PtrInt; const AValue : TSDOByte);overload;
- {$IFDEF HAS_SDO_BYTES}
- procedure insertBytes(const AIndex : PtrInt; AValue : TSDOBytes);overload;
- {$ENDIF HAS_SDO_BYTES}
- {$IFDEF HAS_SDO_CHAR}
- procedure insert(const AIndex : PtrInt; const AValue : TSDOChar);overload;
- {$ENDIF HAS_SDO_CHAR}
- {$IFDEF HAS_SDO_CURRENCY}
- procedure insertCurrency(const AIndex : PtrInt; const AValue : TSDOCurrency);
- {$ENDIF HAS_SDO_CURRENCY}
- procedure insert(const AIndex : PtrInt; const AValue : TSDODate);overload;
- {$IFDEF HAS_SDO_DOUBLE}
- procedure insert(const AIndex : PtrInt; const AValue : TSDODouble);overload;
- {$ENDIF HAS_SDO_DOUBLE}
- {$IFDEF HAS_SDO_FLOAT}
- procedure insert(const AIndex : PtrInt; const AValue : TSDOFloat);overload;
- {$ENDIF HAS_SDO_FLOAT}
- procedure insert(const AIndex : PtrInt; const AValue : TSDOInteger);overload;
- {$IFDEF HAS_SDO_LONG}
- procedure insert(const AIndex : PtrInt; const AValue : TSDOLong);overload;
- {$ENDIF HAS_SDO_LONG}
- {$IFDEF HAS_SDO_SHORT}
- procedure insert(const AIndex : PtrInt; const AValue : TSDOShort);overload;
- {$ENDIF HAS_SDO_SHORT}
- procedure insert(const AIndex : PtrInt; const AValue : TSDOString);overload;
- procedure insert(const AIndex : PtrInt; AValue : ISDODataObject);overload;
- procedure append(const AValue : TSDOBoolean);overload;
- procedure append(const AValue : TSDOByte);overload;
- {$IFDEF HAS_SDO_BYTES}
- procedure appendBytes(AValue : TSDOBytes);overload;
- {$ENDIF HAS_SDO_BYTES}
- {$IFDEF HAS_SDO_CHAR}
- procedure append(const AValue : TSDOChar);overload;
- {$ENDIF HAS_SDO_CHAR}
- {$IFDEF HAS_SDO_CURRENCY}
- procedure appendCurrency(const AValue : TSDOCurrency);
- {$ENDIF HAS_SDO_CURRENCY}
- procedure append(const AValue : TSDODate);overload;
- {$IFDEF HAS_SDO_DOUBLE}
- procedure append(const AValue : TSDODouble);overload;
- {$ENDIF HAS_SDO_DOUBLE}
- {$IFDEF HAS_SDO_FLOAT}
- procedure append(const AValue : TSDOFloat);overload;
- {$ENDIF HAS_SDO_FLOAT}
- procedure append(const AValue : TSDOInteger);overload;
- {$IFDEF HAS_SDO_LONG}
- procedure append(const AValue : TSDOLong);overload;
- {$ENDIF HAS_SDO_LONG}
- {$IFDEF HAS_SDO_SHORT}
- procedure append(const AValue : TSDOShort);overload;
- {$ENDIF HAS_SDO_SHORT}
- procedure append(const AValue : TSDOString);overload;
- procedure append(AValue : ISDODataObject);overload;
- procedure delete(const AIndex : PtrInt);overload;
- procedure delete();overload;
- public
- constructor Create(const AItemType : ISDOType);
- destructor Destroy();override;
- end;
- TSDOOwnedDataObjectList = class(TSDODataObjectList,IInterface,ISDODataObjectList)
- private
- FOwner : Pointer; // do not add a reference count!
- FOwnerProperty : ISDOProperty;
- protected
- procedure RecordChange(const AChange : TManyValuePropAction);overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
- function getOwner() : ISDODataObject;{$IFDEF USE_INLINE}inline;{$ENDIF}
- procedure InternalSetDataObject(const AValue : ISDODataObject; const ADoRecordChange : Boolean);
- protected
- procedure setBoolean(const AValue : TSDOBoolean);overload;
- procedure setByte(const AValue : TSDOByte);overload;
- {$IFDEF HAS_SDO_BYTES}
- procedure setBytes(AValue : TSDOBytes);overload;
- {$ENDIF HAS_SDO_BYTES}
- {$IFDEF HAS_SDO_CHAR}
- procedure setCharacter(const AValue : TSDOChar);overload;
- {$ENDIF HAS_SDO_CHAR}
- {$IFDEF HAS_SDO_CURRENCY}
- procedure setCurrency(const AValue : TSDOCurrency);overload;
- {$ENDIF HAS_SDO_CURRENCY}
- procedure setDate(const AValue : TSDODate);overload;
- {$IFDEF HAS_SDO_DOUBLE}
- procedure setDouble(const AValue : TSDODouble);overload;
- {$ENDIF HAS_SDO_DOUBLE}
- {$IFDEF HAS_SDO_FLOAT}
- procedure setFloat(const AValue : TSDOFloat);overload;
- {$ENDIF HAS_SDO_FLOAT}
- procedure setInteger(const AValue : TSDOInteger);overload;
- {$IFDEF HAS_SDO_LONG}
- procedure setLong(const AValue : TSDOLong);overload;
- {$ENDIF HAS_SDO_LONG}
- {$IFDEF HAS_SDO_SHORT}
- procedure setShort(const AValue : TSDOShort);overload;
- {$ENDIF HAS_SDO_SHORT}
- procedure setString(const AValue : TSDOString);overload;
- procedure setDataObject(AValue : ISDODataObject);overload;
- procedure setVariant(const AValue : TSDOVariant);overload;
- procedure setBoolean(const AIndex : PtrInt; const AValue : TSDOBoolean);overload;
- procedure setByte(const AIndex : PtrInt; const AValue : TSDOByte);overload;
- {$IFDEF HAS_SDO_BYTES}
- procedure setBytes(const AIndex : PtrInt; AValue : TSDOBytes);overload;
- {$ENDIF HAS_SDO_BYTES}
- {$IFDEF HAS_SDO_CHAR}
- procedure setCharacter(const AIndex : PtrInt; const AValue : TSDOChar);overload;
- {$ENDIF HAS_SDO_CHAR}
- {$IFDEF HAS_SDO_CURRENCY}
- procedure setCurrency(const AIndex : PtrInt; const AValue : TSDOCurrency);overload;
- {$ENDIF HAS_SDO_CURRENCY}
- procedure setDate(const AIndex : PtrInt; const AValue : TSDODate);overload;
- {$IFDEF HAS_SDO_DOUBLE}
- procedure setDouble(const AIndex : PtrInt; const AValue : TSDODouble);overload;
- {$ENDIF HAS_SDO_DOUBLE}
- {$IFDEF HAS_SDO_FLOAT}
- procedure setFloat(const AIndex : PtrInt; const AValue : TSDOFloat);overload;
- {$ENDIF HAS_SDO_FLOAT}
- procedure setInteger(const AIndex : PtrInt; const AValue : TSDOInteger);overload;
- {$IFDEF HAS_SDO_LONG}
- procedure setLong(const AIndex : PtrInt; const AValue : TSDOLong);overload;
- {$ENDIF HAS_SDO_LONG}
- {$IFDEF HAS_SDO_SHORT}
- procedure setShort(const AIndex : PtrInt; const AValue : TSDOShort);overload;
- {$ENDIF HAS_SDO_SHORT}
- procedure setString(const AIndex : PtrInt; const AValue : TSDOString);overload;
- procedure setDataObject(const AIndex : PtrInt; AValue : ISDODataObject);overload;
- procedure setVariant(const AIndex : PtrInt; const AValue : TSDOVariant);overload;
- procedure insert(const AIndex : PtrInt; const AValue : TSDOBoolean);overload;
- procedure insert(const AIndex : PtrInt; const AValue : TSDOByte);overload;
- {$IFDEF HAS_SDO_BYTES}
- procedure insertBytes(const AIndex : PtrInt; AValue : TSDOBytes);overload;
- {$ENDIF HAS_SDO_BYTES}
- {$IFDEF HAS_SDO_CHAR}
- procedure insert(const AIndex : PtrInt; const AValue : TSDOChar);overload;
- {$ENDIF HAS_SDO_CHAR}
- {$IFDEF HAS_SDO_CURRENCY}
- procedure insertCurrency(const AIndex : PtrInt; const AValue : TSDOCurrency);
- {$ENDIF HAS_SDO_CURRENCY}
- procedure insert(const AIndex : PtrInt; const AValue : TSDODate);overload;
- {$IFDEF HAS_SDO_DOUBLE}
- procedure insert(const AIndex : PtrInt; const AValue : TSDODouble);overload;
- {$ENDIF HAS_SDO_DOUBLE}
- {$IFDEF HAS_SDO_FLOAT}
- procedure insert(const AIndex : PtrInt; const AValue : TSDOFloat);overload;
- {$ENDIF HAS_SDO_FLOAT}
- procedure insert(const AIndex : PtrInt; const AValue : TSDOInteger);overload;
- {$IFDEF HAS_SDO_LONG}
- procedure insert(const AIndex : PtrInt; const AValue : TSDOLong);overload;
- {$ENDIF HAS_SDO_LONG}
- {$IFDEF HAS_SDO_SHORT}
- procedure insert(const AIndex : PtrInt; const AValue : TSDOShort);overload;
- {$ENDIF HAS_SDO_SHORT}
- procedure insert(const AIndex : PtrInt; const AValue : TSDOString);overload;
- procedure insert(const AIndex : PtrInt; AValue : ISDODataObject);overload;
- procedure append(const AValue : TSDOBoolean);overload;
- procedure append(const AValue : TSDOByte);overload;
- {$IFDEF HAS_SDO_BYTES}
- procedure appendBytes(AValue : TSDOBytes);overload;
- {$ENDIF HAS_SDO_BYTES}
- {$IFDEF HAS_SDO_CHAR}
- procedure append(const AValue : TSDOChar);overload;
- {$ENDIF HAS_SDO_CHAR}
- {$IFDEF HAS_SDO_CURRENCY}
- procedure appendCurrency(const AValue : TSDOCurrency);
- {$ENDIF HAS_SDO_CURRENCY}
- procedure append(const AValue : TSDODate);overload;
- {$IFDEF HAS_SDO_DOUBLE}
- procedure append(const AValue : TSDODouble);overload;
- {$ENDIF HAS_SDO_DOUBLE}
- {$IFDEF HAS_SDO_FLOAT}
- procedure append(const AValue : TSDOFloat);overload;
- {$ENDIF HAS_SDO_FLOAT}
- procedure append(const AValue : TSDOInteger);overload;
- {$IFDEF HAS_SDO_LONG}
- procedure append(const AValue : TSDOLong);overload;
- {$ENDIF HAS_SDO_LONG}
- {$IFDEF HAS_SDO_SHORT}
- procedure append(const AValue : TSDOShort);overload;
- {$ENDIF HAS_SDO_SHORT}
- procedure append(AValue : ISDODataObject);overload;
- procedure append(const AValue : TSDOString);overload;
- procedure delete(const AIndex : PtrInt);overload;
- procedure delete();overload;
- public
- constructor Create(
- const AOwner : ISDODataObject;
- const AProperty : ISDOProperty
- );
- end;
- implementation
- uses
- sdo_imp_utils, sdo_utils;
- { TSDOBaseDataObject }
- procedure TSDOBaseDataObject.clear;
- begin
- end;
- constructor TSDOBaseDataObject.Create(
- const AType: ISDOTypeEx;
- const AContainer : ISDODataObject;
- const AContainerProperty : ISDOProperty
- );
- begin
- if ( AType = nil ) then
- raise ESDOIllegalArgumentException.Create('AType');
- if ( AContainer <> nil ) and ( AContainerProperty = nil ) then
- raise ESDOIllegalArgumentException.Create('AContainerProperty');
- FType := AType as ISDOObjectType;
- FContainer := Pointer(AContainer);
- FContainerProperty := Pointer(AContainerProperty);
- FXPathExpression := TXPathExpression.Create();
- FXPathProcessor := TXPathProcessor.Create();
- PrepareDataBuffer();
- InitializeDefaultValues();
- FType.setUsedFlag(True);
- end;
- function TSDOBaseDataObject.createDataObject(const APath: string): ISDODataObject;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- Result := locCtx.PropertyOwner.createDataObject(locCtx.CurrentProperty);
- end;
- function TSDOBaseDataObject.createDataObject(const AProperty: ISDOProperty) : ISDODataObject;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or ( not Self.IsOwnerOf(AProperty) ) then
- raise ESDOIllegalArgumentException.Create('AProperty');
- prp := AProperty as ISDOPropertyEx;
- Result := TSDOBaseDataObjectClass(Self.ClassType).Create(
- prp.getType() as ISDOTypeEx,
- nil, //Self as ISDODataObject,
- prp
- ) as ISDODataObject;
- if not AProperty.isMany() then
- setDataObject(prp,Result);
- end;
- function TSDOBaseDataObject.createDataObject(const APropertyIndex: PtrUInt): ISDODataObject;
- begin
- Result := createDataObject(getProperty(APropertyIndex));
- end;
- destructor TSDOBaseDataObject.Destroy();
- begin
- FDestroying := True;
- FreeBuffer();
- FType := nil;
- FContainer := nil;
- FContainerProperty := nil;
- FChangeSummary := nil;
- FreeAndNil(FReferenceLinkList);
- FreeAndNil(FXPathExpression);
- FreeAndNil(FXPathProcessor);
- inherited;
- end;
- function TSDOBaseDataObject.getBoolean(const APath: string): TSDOBoolean;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- if ( locCtx.ContentKind = xckList ) then
- Result := locCtx.ListItem.getBoolean()
- else
- Result := locCtx.PropertyOwner.getBoolean(locCtx.CurrentProperty);
- end;
- function TSDOBaseDataObject.getBoolean(const APropertyIndex: PtrUInt): TSDOBoolean;
- begin
- Result := getBoolean(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.getBoolean(const AProperty: ISDOProperty): TSDOBoolean;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or
- ( not Self.IsOwnerOf(AProperty) ) or
- ( AProperty.isMany() )
- then begin
- raise ESDOIllegalArgumentException.Create('AProperty');
- end;
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).getBoolean(FBuffer,prp.getBufferOffset());
- end;
- function TSDOBaseDataObject.getByte(const APath: string): TSDOByte;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- if ( locCtx.ContentKind = xckList ) then
- Result := locCtx.ListItem.getByte()
- else
- Result := locCtx.PropertyOwner.getByte(locCtx.CurrentProperty);
- end;
- function TSDOBaseDataObject.getByte(const APropertyIndex: PtrUInt): TSDOByte;
- begin
- Result := getByte(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.getByte(const AProperty: ISDOProperty): TSDOByte;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or
- ( not Self.IsOwnerOf(AProperty) ) or
- ( AProperty.isMany() )
- then begin
- raise ESDOIllegalArgumentException.Create('AProperty');
- end;
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).getByte(FBuffer,prp.getBufferOffset());
- end;
- {$IFDEF HAS_SDO_BYTES}
- function TSDOBaseDataObject.getBytes(const AProperty: ISDOProperty): TSDOBytes;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or
- ( not Self.IsOwnerOf(AProperty) ) or
- ( AProperty.isMany() )
- then begin
- raise ESDOIllegalArgumentException.Create('AProperty');
- end;
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).getBytes(FBuffer,prp.getBufferOffset());
- end;
- function TSDOBaseDataObject.getBytes(const APath: string): TSDOBytes;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- if ( locCtx.ContentKind = xckList ) then
- Result := locCtx.ListItem.getBytes()
- else
- Result := locCtx.PropertyOwner.getBytes(locCtx.CurrentProperty);
- end;
- function TSDOBaseDataObject.getBytes(const APropertyIndex: PtrUInt): TSDOBytes;
- begin
- Result := getBytes(getProperty(APropertyIndex));
- end;
- {$ENDIF HAS_SDO_BYTES}
- function TSDOBaseDataObject.getCharacter(const AProperty: ISDOProperty): TSDOChar;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or
- ( not Self.IsOwnerOf(AProperty) ) or
- ( AProperty.isMany() )
- then begin
- raise ESDOIllegalArgumentException.Create('AProperty');
- end;
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).getCharacter(FBuffer,prp.getBufferOffset());
- end;
- function TSDOBaseDataObject.getCharacter(const APropertyIndex: PtrUInt): TSDOChar;
- begin
- Result := getCharacter(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.getCharacter(const APath: string): TSDOChar;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- if ( locCtx.ContentKind = xckList ) then
- Result := locCtx.ListItem.getCharacter()
- else
- Result := locCtx.PropertyOwner.getCharacter(locCtx.CurrentProperty);
- end;
- function TSDOBaseDataObject.getContainer() : ISDODataObject;
- begin
- Result := ISDODataObject(FContainer);
- end;
- function TSDOBaseDataObject.getContainmentProperty() : ISDOProperty;
- begin
- if not Assigned(FContainerProperty) then
- raise ESDOPropertyNotFoundException.Create('ContainmentProperty');
- Result := ISDOProperty(FContainerProperty);
- end;
- {$IFDEF HAS_SDO_CURRENCY }
- function TSDOBaseDataObject.getCurrency(const AProperty: ISDOProperty): TSDOCurrency;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or
- ( not Self.IsOwnerOf(AProperty) ) or
- ( AProperty.isMany() )
- then begin
- raise ESDOIllegalArgumentException.Create('AProperty');
- end;
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).getCurrency(FBuffer,prp.getBufferOffset());
- end;
- function TSDOBaseDataObject.getCurrency(const APropertyIndex: PtrUInt): TSDOCurrency;
- begin
- Result := getCurrency(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.getCurrency(const APath: string): TSDOCurrency;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- if ( locCtx.ContentKind = xckList ) then
- Result := locCtx.ListItem.getCurrency()
- else
- Result := locCtx.PropertyOwner.getCurrency(locCtx.CurrentProperty);
- end;
- {$ENDIF HAS_SDO_CURRENCY }
- function TSDOBaseDataObject.getDataObject(const APath: string): ISDODataObject;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- Result := locCtx.ObjectItem;
- {if ( locCtx.ContentKind = xckList ) then
- Result := locCtx.ListItem.getDataObject()
- else
- Result := locCtx.PropertyOwner.getDataObject(locCtx.CurrentProperty);}
- end;
- function TSDOBaseDataObject.getDataObject(const APropertyIndex: PtrUInt): ISDODataObject;
- begin
- Result := getDataObject(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.getDataObject(const AProperty: ISDOProperty): ISDODataObject;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or ( not Self.IsOwnerOf(AProperty) ) then
- raise ESDOIllegalArgumentException.Create('AProperty');
- if AProperty.isMany() then begin
- Result := getList(AProperty).getDataObject();
- end else begin
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).getDataObject(FBuffer,prp.getBufferOffset());
- end;
- end;
- function TSDOBaseDataObject.getDate(const APropertyIndex: PtrUInt): TSDODate;
- begin
- Result := getDate(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.getDate(const APath: string): TSDODate;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- if ( locCtx.ContentKind = xckList ) then
- Result := locCtx.ListItem.getDate()
- else
- Result := locCtx.PropertyOwner.getDate(locCtx.CurrentProperty);
- end;
- function TSDOBaseDataObject.getDate(const AProperty: ISDOProperty): TSDODate;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or
- ( not Self.IsOwnerOf(AProperty) ) or
- ( AProperty.isMany() )
- then begin
- raise ESDOIllegalArgumentException.Create('AProperty');
- end;
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).getDate(FBuffer,prp.getBufferOffset());
- end;
- {$IFDEF HAS_SDO_DOUBLE }
- function TSDOBaseDataObject.getDouble(const AProperty: ISDOProperty): TSDODouble;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or
- ( not Self.IsOwnerOf(AProperty) ) or
- ( AProperty.isMany() )
- then begin
- raise ESDOIllegalArgumentException.Create('AProperty');
- end;
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).getDouble(FBuffer,prp.getBufferOffset());
- end;
- function TSDOBaseDataObject.getDouble(const APropertyIndex: PtrUInt): TSDODouble;
- begin
- Result := getDouble(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.getDouble(const APath: string): TSDODouble;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- if ( locCtx.ContentKind = xckList ) then
- Result := locCtx.ListItem.getDouble()
- else
- Result := locCtx.PropertyOwner.getDouble(locCtx.CurrentProperty);
- end;
- {$ENDIF HAS_SDO_DOUBLE }
- {$IFDEF HAS_SDO_FLOAT }
- function TSDOBaseDataObject.getFloat(const AProperty: ISDOProperty): TSDOFloat;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or
- ( not Self.IsOwnerOf(AProperty) ) or
- ( AProperty.isMany() )
- then begin
- raise ESDOIllegalArgumentException.Create('AProperty');
- end;
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).getFloat(FBuffer,prp.getBufferOffset());
- end;
- function TSDOBaseDataObject.getFloat(const APropertyIndex: PtrUInt): TSDOFloat;
- begin
- Result := getFloat(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.getFloat(const APath: string): TSDOFloat;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- if ( locCtx.ContentKind = xckList ) then
- Result := locCtx.ListItem.getFloat()
- else
- Result := locCtx.PropertyOwner.getFloat(locCtx.CurrentProperty);
- end;
- {$ENDIF HAS_SDO_FLOAT }
- function TSDOBaseDataObject.getInstanceProperties() : ISDOPropertyList;
- begin
- Result := FType.getProperties();
- end;
- function TSDOBaseDataObject.getInteger(const AProperty: ISDOProperty): TSDOInteger;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or
- ( not Self.IsOwnerOf(AProperty) ) or
- ( AProperty.isMany() )
- then begin
- raise ESDOIllegalArgumentException.Create('AProperty');
- end;
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).getInteger(FBuffer,prp.getBufferOffset());
- end;
- function TSDOBaseDataObject.getInteger(const APropertyIndex: PtrUInt): TSDOInteger;
- begin
- Result := getInteger(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.getInteger(const APath: string): TSDOInteger;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- if ( locCtx.ContentKind = xckList ) then
- Result := locCtx.ListItem.getInteger()
- else
- Result := locCtx.PropertyOwner.getInteger(locCtx.CurrentProperty);
- end;
- function TSDOBaseDataObject.getLong(const AProperty: ISDOProperty): TSDOLong;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or
- ( not Self.IsOwnerOf(AProperty) ) or
- ( AProperty.isMany() )
- then begin
- raise ESDOIllegalArgumentException.Create('AProperty');
- end;
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).getLong(FBuffer,prp.getBufferOffset());
- end;
- function TSDOBaseDataObject.getLong(const APropertyIndex: PtrUInt): TSDOLong;
- begin
- Result := getLong(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.getLong(const APath: string): TSDOLong;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- if ( locCtx.ContentKind = xckList ) then
- Result := locCtx.ListItem.getLong()
- else
- Result := locCtx.PropertyOwner.getLong(locCtx.CurrentProperty);
- end;
- function TSDOBaseDataObject.getProperty(const AIndex: PtrUInt): ISDOProperty;
- begin
- Result := getInstanceProperties().getItem(AIndex);//FType.getProperty(AIndex);
- end;
- function TSDOBaseDataObject.getProperty(const AProp: string): ISDOProperty;
- begin
- Result := getInstanceProperties().find(AProp);
- if ( Result = nil ) then
- raise ESDOPropertyNotFoundException.Create(AProp);
- end;
- function TSDOBaseDataObject.getPropertyIndex(const AProperty: ISDOProperty): PtrInt;
- begin
- Result := FType.getPropertyIndex(AProperty.getName());
- end;
- function TSDOBaseDataObject.getShort(const APropertyIndex: PtrUInt): TSDOShort;
- begin
- Result := getShort(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.getShort(const APath: string): TSDOShort;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- if ( locCtx.ContentKind = xckList ) then
- Result := locCtx.ListItem.getShort()
- else
- Result := locCtx.PropertyOwner.getShort(locCtx.CurrentProperty);
- end;
- function TSDOBaseDataObject.getShort(const AProperty: ISDOProperty): TSDOShort;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or
- ( not Self.IsOwnerOf(AProperty) ) or
- ( AProperty.isMany() )
- then begin
- raise ESDOIllegalArgumentException.Create('AProperty');
- end;
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).getShort(FBuffer,prp.getBufferOffset());
- end;
- function TSDOBaseDataObject.getString(const AProperty: ISDOProperty): TSDOString;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or
- ( not Self.IsOwnerOf(AProperty) ) or
- ( AProperty.isMany() )
- then begin
- raise ESDOIllegalArgumentException.Create('AProperty');
- end;
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).getString(FBuffer,prp.getBufferOffset());
- end;
- function TSDOBaseDataObject.getString(const APropertyIndex: PtrUInt): TSDOString;
- begin
- Result := getString(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.getString(const APath: string): TSDOString;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- if ( locCtx.ContentKind = xckList ) then
- Result := locCtx.ListItem.getString()
- else
- Result := locCtx.PropertyOwner.getString(locCtx.CurrentProperty);
- end;
- function TSDOBaseDataObject.getType() : ISDOType;
- begin
- Result := FType as ISDOType;
- end;
- function TSDOBaseDataObject.getTypeEnum() : TSDOTypeKind;
- begin
- Result := FType.getTypeEnum();
- end;
- function TSDOBaseDataObject.isNull(const APath: string): Boolean;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- case locCtx.ContentKind of
- xckNull : Result := True;
- xckObject : Result := False;
- xckList :
- begin
- Result := locCtx.CurrentProperty.getType().isDataObjectType and ( locCtx.ListItem.getDataObject() = nil );
- end;
- xckValue : Result := locCtx.ObjectItem.isNull(locCtx.CurrentProperty);
- else
- Result := False;
- end;
- end;
- function TSDOBaseDataObject.isNull(const AProperty: ISDOProperty): Boolean;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or ( not Self.IsOwnerOf(AProperty) ) then
- raise ESDOIllegalArgumentException.Create('AProperty');
- if AProperty.isMany() then begin
- Result := ( getList(AProperty).size > 0 );
- end else begin
- prp := AProperty as ISDOPropertyEx;
- Result := getField(prp.getTypeEnum()).isNull(FBuffer,prp.getBufferOffset());
- end;
- end;
- function TSDOBaseDataObject.isNull(const APropertyIndex: PtrUInt): Boolean;
- begin
- Result := isNull(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.isSet(const APropertyIndex: PtrUInt): Boolean;
- begin
- Result := isSet(getProperty(APropertyIndex));
- end;
- function TSDOBaseDataObject.isSet(const APath: string): Boolean;
- var
- locCtx : TXPathExecContext;
- begin
- locCtx := parsePropertyPath(APath);
- if ( locCtx.PropertyOwner = nil ) then
- raise ESDOInvalidPathException.Create(APath);
- case locCtx.ContentKind of
- xckNull : Result := not locCtx.PropertyOwner.getType().isDataObjectType();
- xckObject : Result := locCtx.PropertyOwner.isSet(locCtx.CurrentProperty);
- xckList : Result := ( locCtx.ListItem.size() > 0 );
- xckValue : Result := locCtx.ObjectItem.isSet(locCtx.CurrentProperty);
- else
- Result := False;
- end;
- end;
- function TSDOBaseDataObject.isSet(const AProperty: ISDOProperty): Boolean;
- var
- prp : ISDOPropertyEx;
- begin
- if ( AProperty = nil ) or ( not Self.IsOwnerOf(AProperty) ) then
- raise ESDOIllegalArgumentException.Create('AProperty');
- if AProperty.isMany() then begin
- Result := ( getList(AP…