/packages/fcl-sdo/src/base/sdo_dataobject.pas
Pascal | 4199 lines | 3467 code | 408 blank | 324 comment | 324 complexity | 2b95a80fc937a285b144f14dee5a4de0 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
Large files files are truncated, but you can click here to view the full file
1{ 2 This file is part of the Free Pascal Class Library SDO Implementation 3 Copyright (c) 2012 by Inoussa OUEDRAOGO 4 Free Pascal development team 5 6 This unit implements the basic SDO objects 7 8 See the file COPYING.FPC, included in this distribution, 9 for details about the copyright. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 15 **********************************************************************} 16{$INCLUDE sdo_global.inc} 17unit sdo_dataobject; 18 19interface 20uses 21 SysUtils, Classes, Contnrs, 22 sdo_types, sdo, sdo_type, sdo_changesummary, sdo_xpath_helper, sdo_linked_list, 23 sdo_field_imp; 24 25type 26 27 IDataObjectObserver = interface 28 ['{EF23F339-EF10-4312-B202-43AA5C743841}'] 29 procedure NotifyDeletion( 30 const ADataObject : ISDODataObject; 31 const AProperty : ISDOProperty 32 ); 33 end; 34 35 ISDODataObjectEx = interface(ISDODataObject) 36 ['{2EA33304-D190-425F-A952-685619896AB2}'] 37 //Return TRUE if this instance is an instance or a derived class 38 function IsInstanceOf(const AType : ISDOType) : Boolean; 39 40 function IsAncestorOf(const AObject : ISDODataObject) : Boolean; 41 procedure setContainer( 42 const AContainer : ISDODataObject; 43 const AContainerProperty : ISDOProperty 44 ); 45 procedure AddReference( 46 const AReferencer : ISDODataObject; 47 const AReferenceProperty : ISDOProperty 48 ); 49 procedure RemoveReference( 50 const AReferencer : ISDODataObject; 51 const AReferenceProperty : ISDOProperty 52 ); 53 procedure NotifyContainedObjectsForDeletion(const ACallFromParent : Boolean);// logical deletion 54 55 // for open Type support 56 procedure addProperty( 57 const APropName : string; 58 const APropType : ISDOType; 59 const AFlags : TPropertyFlags 60 ); 61 end; 62 63 TObserverInfo = class 64 private 65 FDataObject : Pointer; 66 FRefProperty : Pointer; 67 public 68 constructor Create(const ADataObject : ISDODataObject; const ARefProperty : ISDOProperty); 69 function GetDataObject() : ISDODataObject;{$IFDEF USE_INLINE}inline;{$ENDIF} 70 function GetRefProperty() : ISDOProperty;{$IFDEF USE_INLINE}inline;{$ENDIF} 71 end; 72 73 TDataObjectObserverList = class 74 private 75 FList : TObjectList; 76 public 77 constructor Create(); 78 destructor Destroy();override; 79 procedure Add(const ADataObject : ISDODataObject; const ARefProperty : ISDOProperty);{$IFDEF USE_INLINE}inline;{$ENDIF} 80 function IndexOf(const ADataObject : ISDODataObject; const ARefProperty : ISDOProperty) : PtrInt; 81 function Find(const ADataObject : ISDODataObject; const ARefProperty : ISDOProperty) : TObserverInfo;{$IFDEF USE_INLINE}inline;{$ENDIF} 82 function GetCount() : PtrInt;{$IFDEF USE_INLINE}inline;{$ENDIF} 83 function GetItem(const AIndex : PtrInt) : TObserverInfo;{$IFDEF USE_INLINE}inline;{$ENDIF} 84 function Extract(const AIndex : PtrInt) : TObserverInfo;{$IFDEF USE_INLINE}inline;{$ENDIF} 85 procedure Delete(const AIndex : PtrInt);{$IFDEF USE_INLINE}inline;{$ENDIF} 86 end; 87 88 TSDOBaseDataObjectClass = class of TSDOBaseDataObject; 89 TSDOBaseDataObject = class( 90 TInterfacedObject, 91 IInterface, 92 ISDODataObject, 93 ISDODataObjectEx, 94 IDataObjectObserver 95 ) 96 private 97 FDestroying : Boolean; 98 FType : ISDOObjectType; 99 FContainer : Pointer; 100 FContainerProperty : Pointer; 101 FBuffer : TSDOFieldBuffer; 102 FBufferLength : PtrUInt; 103 FChangeSummary : Pointer;//ISDOChangeSummaryEx; 104 FReferenceLinkList : TDataObjectObserverList; 105 private 106 FXPathExpression : TXPathExpression; 107 FXPathProcessor : TXPathProcessor; 108 protected 109 function _Release: LongInt; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF}; 110 procedure PrepareDataBuffer(); 111 procedure FreeBuffer(); 112 function parsePropertyPath(const APath : string) : TXPathExecContext; 113 function IsOwnerOf(const AProp : ISDOProperty) : Boolean;virtual;//{$IFDEF USE_INLINE}inline;{$ENDIF} 114 function CreateList(const AProperty : ISDOProperty) : ISDODataObjectList;{$IFDEF USE_INLINE}inline;{$ENDIF} 115 procedure InitializeDefaultValues(); 116 protected 117 procedure RecordChange(const AProperty : ISDOProperty);{$IFDEF USE_INLINE}inline;{$ENDIF} 118 procedure NotifyReferencersForDeletion(); 119 protected 120 // ISDODataObjectEx 121 function IsInstanceOf(const AType : ISDOType) : Boolean; 122 function IsAncestorOf(const AObject : ISDODataObject) : Boolean; 123 procedure setContainer( 124 const AContainer : ISDODataObject; 125 const AContainerProperty : ISDOProperty 126 ); 127 128 //ISDODataObject 129 function getPropertyIndex(const AProperty : ISDOProperty) : PtrInt; 130 function getInstanceProperties() : ISDOPropertyList;virtual; 131 132 function getProperty(const AIndex : PtrUInt) : ISDOProperty;overload; 133 function getProperty(const AProp : string) : ISDOProperty;overload; 134 135 function getContainer() : ISDODataObject; 136 function getContainmentProperty() : ISDOProperty; 137 function getType() : ISDOType; 138 function getTypeEnum() : TSDOTypeKind; 139 140 function getList(const APath : string) : ISDODataObjectList; overload; 141 function getList(const APropertyIndex : PtrUInt) : ISDODataObjectList; overload; 142 function getList(const AProperty : ISDOProperty) : ISDODataObjectList; overload; 143 144 function getDataObject(const APath : string) : ISDODataObject; overload; 145 function getDataObject(const APropertyIndex : PtrUInt) : ISDODataObject; overload; 146 function getDataObject(const AProperty : ISDOProperty) : ISDODataObject; overload; 147 148 procedure setDataObject(const APath : string; AValue : ISDODataObject); overload; virtual; 149 procedure setDataObject(const APropertyIndex : PtrUInt; AValue : ISDODataObject); overload; 150 procedure setDataObject(const AProperty : ISDOProperty; AValue : ISDODataObject); overload; 151 152 function getBoolean(const APath : string) : TSDOBoolean; overload; 153 function getBoolean(const APropertyIndex : PtrUInt) : TSDOBoolean; overload; 154 function getBoolean(const AProperty : ISDOProperty) : TSDOBoolean; overload; 155 156 procedure setBoolean(const APath : string; const AValue : TSDOBoolean); overload; virtual; 157 procedure setBoolean(const APropertyIndex : PtrUInt; const AValue : TSDOBoolean); overload; 158 procedure setBoolean(const AProperty : ISDOProperty; const AValue : TSDOBoolean); overload; 159 160 function getByte(const APath : string) : TSDOByte;overload; 161 function getByte(const APropertyIndex : PtrUInt) : TSDOByte;overload; 162 function getByte(const AProperty : ISDOProperty) : TSDOByte;overload; 163 164 procedure setByte(const APath : string; const AValue : TSDOByte);overload; virtual; 165 procedure setByte(const APropertyIndex : PtrUInt; const AValue : TSDOByte);overload; 166 procedure setByte(const AProperty : ISDOProperty; const AValue : TSDOByte);overload; 167 168{$IFDEF HAS_SDO_CHAR} 169 function getCharacter(const APath : string) : TSDOChar;overload; 170 function getCharacter(const APropertyIndex : PtrUInt) : TSDOChar;overload; 171 function getCharacter(const AProperty : ISDOProperty) : TSDOChar;overload; 172 173 procedure setCharacter(const APath : string; const AValue : TSDOChar);overload; virtual; 174 procedure setCharacter(const APropertyIndex : PtrUInt; const AValue : TSDOChar);overload; 175 procedure setCharacter(const AProperty : ISDOProperty; const AValue : TSDOChar);overload; 176{$ENDIF HAS_SDO_CHAR} 177 178{$IFDEF HAS_SDO_BYTES} 179 function getBytes(const APath : string) : TSDOBytes;overload; 180 function getBytes(const APropertyIndex : PtrUInt) : TSDOBytes;overload; 181 function getBytes(const AProperty : ISDOProperty) : TSDOBytes;overload; 182 183 procedure setBytes(const APath : string; AValue : TSDOBytes);overload; virtual; 184 procedure setBytes(const APropertyIndex : PtrUInt; AValue : TSDOBytes);overload; 185 procedure setBytes(const AProperty : ISDOProperty; AValue : TSDOBytes);overload; 186{$ENDIF HAS_SDO_BYTES} 187 188{$IFDEF HAS_SDO_CURRENCY} 189 function getCurrency(const APath : string) : TSDOCurrency;overload; 190 function getCurrency(const APropertyIndex : PtrUInt) : TSDOCurrency;overload; 191 function getCurrency(const AProperty : ISDOProperty) : TSDOCurrency;overload; 192 193 procedure setCurrency(const APath : string; const AValue : TSDOCurrency);overload; virtual; 194 procedure setCurrency(const APropertyIndex : PtrUInt; const AValue : TSDOCurrency);overload; 195 procedure setCurrency(const AProperty : ISDOProperty; const AValue : TSDOCurrency);overload; 196{$ENDIF HAS_SDO_CURRENCY} 197 198 function getString(const APath : string) : TSDOString;overload; 199 function getString(const APropertyIndex : PtrUInt) : TSDOString;overload; 200 function getString(const AProperty : ISDOProperty) : TSDOString;overload; 201 202 procedure setString(const APath : string; const AValue : TSDOString);overload;virtual; 203 procedure setString(const APropertyIndex : PtrUInt; const AValue : TSDOString);overload; 204 procedure setString(const AProperty : ISDOProperty; const AValue : TSDOString);overload; 205 206 function getDate(const APath : string) : TSDODate;overload; 207 function getDate(const APropertyIndex : PtrUInt) : TSDODate;overload; 208 function getDate(const AProperty : ISDOProperty) : TSDODate;overload; 209 210 procedure setDate(const APath : string; const AValue : TSDODate);overload;virtual; 211 procedure setDate(const APropertyIndex : PtrUInt; const AValue : TSDODate);overload; 212 procedure setDate(const AProperty : ISDOProperty; const AValue : TSDODate);overload; 213 214{$IFDEF HAS_SDO_DOUBLE} 215 function getDouble(const APath : string) : TSDODouble;overload; 216 function getDouble(const APropertyIndex : PtrUInt) : TSDODouble;overload; 217 function getDouble(const AProperty : ISDOProperty) : TSDODouble;overload; 218 219 procedure setDouble(const APath : string; const AValue : TSDODouble);overload; virtual; 220 procedure setDouble(const APropertyIndex : PtrUInt; const AValue : TSDODouble);overload; 221 procedure setDouble(const AProperty : ISDOProperty; const AValue : TSDODouble);overload; 222{$ENDIF HAS_SDO_DOUBLE} 223 224{$IFDEF HAS_SDO_FLOAT} 225 function getFloat(const APath : string) : TSDOFloat;overload; 226 function getFloat(const APropertyIndex : PtrUInt) : TSDOFloat;overload; 227 function getFloat(const AProperty : ISDOProperty) : TSDOFloat;overload; 228 229 procedure setFloat(const APath : string; const AValue : TSDOFloat);overload; virtual; 230 procedure setFloat(const APropertyIndex : PtrUInt; const AValue : TSDOFloat);overload; 231 procedure setFloat(const AProperty : ISDOProperty; const AValue : TSDOFloat);overload; 232{$ENDIF HAS_SDO_FLOAT} 233 234 function getInteger(const APath : string) : TSDOInteger;overload; 235 function getInteger(const APropertyIndex : PtrUInt) : TSDOInteger;overload; 236 function getInteger(const AProperty : ISDOProperty) : TSDOInteger;overload; 237 238 procedure setInteger(const APath : string; const AValue : TSDOInteger);overload;virtual; 239 procedure setInteger(const APropertyIndex : PtrUInt; const AValue : TSDOInteger);overload; 240 procedure setInteger(const AProperty : ISDOProperty; const AValue : TSDOInteger);overload; 241 242{$IFDEF HAS_SDO_LONG} 243 function getLong(const APath : string) : TSDOLong;overload; 244 function getLong(const APropertyIndex : PtrUInt) : TSDOLong;overload; 245 function getLong(const AProperty : ISDOProperty) : TSDOLong;overload; 246 247 procedure setLong(const APath : string; const AValue : TSDOLong);overload; virtual; 248 procedure setLong(const APropertyIndex : PtrUInt; const AValue : TSDOLong);overload; 249 procedure setLong(const AProperty : ISDOProperty; const AValue : TSDOLong);overload; 250{$ENDIF HAS_SDO_LONG} 251 252{$IFDEF HAS_SDO_SHORT} 253 function getShort(const APath : string) : TSDOShort;overload; 254 function getShort(const APropertyIndex : PtrUInt) : TSDOShort;overload; 255 function getShort(const AProperty : ISDOProperty) : TSDOShort;overload; 256 257 procedure setShort(const APath : string; const AValue : TSDOShort);overload; virtual; 258 procedure setShort(const APropertyIndex : PtrUInt; const AValue : TSDOShort);overload; 259 procedure setShort(const AProperty : ISDOProperty; const AValue : TSDOShort);overload; 260{$ENDIF HAS_SDO_SHORT} 261 262 function getVariant(const APath : string) : TSDOVariant;overload; 263 function getVariant(const APropertyIndex : PtrUInt) : TSDOVariant;overload; 264 function getVariant(const AProperty : ISDOProperty) : TSDOVariant;overload; 265 266 procedure setVariant(const APath : string; const AValue : TSDOVariant);overload; 267 procedure setVariant(const APropertyIndex : PtrUInt; const AValue : TSDOVariant);overload; 268 procedure setVariant(const AProperty : ISDOProperty; const AValue : TSDOVariant);overload; 269 270 procedure setNull(const APath : string);overload; 271 procedure setNull(const APropertyIndex : PtrUInt);overload; 272 procedure setNull(const AProperty : ISDOProperty);overload; 273 274 function isNull(const APath : string) : Boolean;overload; 275 function isNull(const APropertyIndex : PtrUInt) : Boolean;overload; 276 function isNull(const AProperty : ISDOProperty) : Boolean;overload; 277 278 function isSet(const APath : string) : Boolean;overload; 279 function isSet(const APropertyIndex : PtrUInt) : Boolean;overload; 280 function isSet(const AProperty : ISDOProperty) : Boolean;overload; 281 282 procedure unset(const APath : string);overload; 283 procedure unset(const APropertyIndex : PtrUInt);overload; 284 procedure unset(const AProperty : ISDOProperty);overload; 285 286 function createDataObject(const APath : string) : ISDODataObject; overload; 287 function createDataObject(const APropertyIndex : PtrUInt) : ISDODataObject; overload; 288 function createDataObject(const AProperty : ISDOProperty) : ISDODataObject; overload; 289 290 function getChangeSummary() : ISDOChangeSummary;overload; 291 {function getChangeSummary(const APath : string) : ISDOChangeSummary;overload; 292 function getChangeSummary(const APropIndex : PtrUInt) : ISDOChangeSummary;overload; 293 function getChangeSummary(const AProp : ISDOProperty ) : ISDOChangeSummary;overload; 294 } 295 procedure clear(); 296 297 // IDataObjectObserver implementation 298 procedure NotifyDeletion( 299 const ADataObject : ISDODataObject; 300 const AProperty : ISDOProperty 301 ); 302 procedure AddReference( 303 const AReferencer : ISDODataObject; 304 const AReferenceProperty : ISDOProperty 305 ); 306 procedure RemoveReference( 307 const AReferencer : ISDODataObject; 308 const AReferenceProperty : ISDOProperty 309 ); 310 procedure NotifyContainedObjectsForDeletion(const ACallFromParent : Boolean);// logical deletion 311 // for open Type support 312 procedure addProperty( 313 const APropName : string; 314 const APropType : ISDOType; 315 const AFlags : TPropertyFlags 316 ); 317 public 318 constructor Create( 319 const AType : ISDOTypeEx; 320 const AContainer : ISDODataObject; 321 const AContainerProperty : ISDOProperty 322 );virtual; 323 destructor Destroy();override; 324 end; 325 326 TSDODataObject = class(TSDOBaseDataObject, IInterface, ISDODataObject) 327 end; 328 329 TSDOOpenedDataObject = class( 330 TSDOBaseDataObject, 331 IInterface, 332 ISDODataObject, 333 ISDODataObjectEx 334 ) 335 private 336 FInstanceProperties : ISDOPropertyListEx; 337 protected 338 function IsOwnerOf(const AProp : ISDOProperty) : Boolean; override; 339 function getInstanceProperties() : ISDOPropertyList;override; 340 procedure setBoolean(const APath : string; const AValue : TSDOBoolean); overload; override; 341 procedure setByte(const APath : string; const AValue : TSDOByte); overload; override; 342{$IFDEF HAS_SDO_BYTES} 343 procedure setBytes(const APath : string; AValue : TSDOBytes); overload; override; 344{$ENDIF HAS_SDO_BYTES} 345{$IFDEF HAS_SDO_CHAR} 346 procedure setCharacter(const APath : string; const AValue : TSDOChar); overload; override; 347{$ENDIF HAS_SDO_CHAR} 348{$IFDEF HAS_SDO_CURRENCY} 349 procedure setCurrency(const APath : string; const AValue : Currency); overload; override; 350{$ENDIF HAS_SDO_CURRENCY} 351 procedure setDate(const APath : string; const AValue : TSDODate);overload;override; 352{$IFDEF HAS_SDO_DOUBLE} 353 procedure setDouble(const APath : string; const AValue : TSDODouble); overload; override; 354{$ENDIF HAS_SDO_DOUBLE} 355{$IFDEF HAS_SDO_FLOAT} 356 procedure setFloat(const APath : string; const AValue : TSDOFloat); overload; override; 357{$ENDIF HAS_SDO_FLOAT} 358 procedure setInteger(const APath : string; const AValue : TSDOInteger);overload;override; 359{$IFDEF HAS_SDO_LONG} 360 procedure setLong(const APath : string; const AValue : TSDOLong); overload; override; 361{$ENDIF HAS_SDO_LONG} 362{$IFDEF HAS_SDO_SHORT} 363 procedure setShort(const APath : string; const AValue : TSDOShort); overload; override; 364{$ENDIF HAS_SDO_SHORT} 365 procedure setString(const APath : string; const AValue : TSDOString);overload;override; 366 procedure setDataObject(const APath : string; AValue : ISDODataObject); overload; override; 367 368 // for open Type support 369 procedure addProperty( 370 const APropName : string; 371 const APropType : ISDOType; 372 const AFlags : TPropertyFlags 373 ); 374 public 375 constructor Create( 376 const AType : ISDOTypeEx; 377 const AContainer : ISDODataObject; 378 const AContainerProperty : ISDOProperty 379 );override; 380 end; 381 382 TSDODataObjectList = class(TInterfacedObject,IInterface,ISDODataObjectList) 383 private 384 FItemType : ISDOType; 385 FData : TDoubleLinkedList; 386 FCursor : ILinkedListCursor; 387 FField : ISDOField; 388 private 389 procedure Clear(); 390 procedure InternalDelete(const AData : PLinkedNode);{$IFDEF USE_INLINE}inline;{$ENDIF} 391 function InternalAppend() : PLinkedNode;{$IFDEF USE_INLINE}inline;{$ENDIF} 392 procedure CheckCursorPosition();{$IFDEF USE_INLINE}inline;{$ENDIF} 393 procedure MoveTo(const AIndex : PtrInt);{$IFDEF USE_INLINE}inline;{$ENDIF} 394 protected 395 function getItemType() : ISDOType;{$IFDEF USE_INLINE}inline;{$ENDIF} 396 function size() : PtrInt; 397 function getCursor() : ILinkedListCursor; 398 399 {These operations use the cursor location} 400 function getBoolean() : TSDOBoolean;overload; 401 function getByte() : TSDOByte;overload; 402{$IFDEF HAS_SDO_BYTES} 403 function getBytes() : TSDOBytes;overload; 404{$ENDIF HAS_SDO_BYTES} 405{$IFDEF HAS_SDO_CHAR} 406 function getCharacter() : TSDOChar;overload; 407{$ENDIF HAS_SDO_CHAR} 408{$IFDEF HAS_SDO_CURRENCY} 409 function getCurrency() : TSDOCurrency;overload; 410{$ENDIF HAS_SDO_CURRENCY} 411 function getDate() : TSDODate;overload; 412{$IFDEF HAS_SDO_DOUBLE} 413 function getDouble() : TSDODouble;overload; 414{$ENDIF HAS_SDO_DOUBLE} 415{$IFDEF HAS_SDO_FLOAT} 416 function getFloat() : TSDOFloat;overload; 417{$ENDIF HAS_SDO_FLOAT} 418 function getInteger() : TSDOInteger;overload; 419{$IFDEF HAS_SDO_LONG} 420 function getLong() : TSDOLong;overload; 421{$ENDIF HAS_SDO_LONG} 422{$IFDEF HAS_SDO_SHORT} 423 function getShort() : TSDOShort;overload; 424{$ENDIF HAS_SDO_SHORT} 425 function getString() : TSDOString;overload; 426 function getDataObject() : ISDODataObject;overload; 427 function getVariant() : TSDOVariant;overload; 428 429 430 procedure setBoolean(const AValue : TSDOBoolean);overload; 431 procedure setByte(const AValue : TSDOByte);overload; 432{$IFDEF HAS_SDO_BYTES} 433 procedure setBytes(AValue : TSDOBytes);overload; 434{$ENDIF HAS_SDO_BYTES} 435{$IFDEF HAS_SDO_CHAR} 436 procedure setCharacter(const AValue : TSDOChar);overload; 437{$ENDIF HAS_SDO_CHAR} 438{$IFDEF HAS_SDO_CURRENCY} 439 procedure setCurrency(const AValue : TSDOCurrency);overload; 440{$ENDIF HAS_SDO_CURRENCY} 441 procedure setDate(const AValue : TSDODate);overload; 442{$IFDEF HAS_SDO_DOUBLE} 443 procedure setDouble(const AValue : TSDODouble);overload; 444{$ENDIF HAS_SDO_DOUBLE} 445{$IFDEF HAS_SDO_FLOAT} 446 procedure setFloat(const AValue : TSDOFloat);overload; 447{$ENDIF HAS_SDO_FLOAT} 448 procedure setInteger(const AValue : TSDOInteger);overload; 449{$IFDEF HAS_SDO_LONG} 450 procedure setLong(const AValue : TSDOLong);overload; 451{$ENDIF HAS_SDO_LONG} 452{$IFDEF HAS_SDO_SHORT} 453 procedure setShort(const AValue : TSDOShort);overload; 454{$ENDIF HAS_SDO_SHORT} 455 procedure setString(const AValue : TSDOString);overload; 456 procedure setDataObject(AValue : ISDODataObject);overload; 457 procedure setVariant(const AValue : TSDOVariant);overload; 458 459 460 function getBoolean(const AIndex : PtrInt) : TSDOBoolean;overload; 461 function getByte(const AIndex : PtrInt) : TSDOByte;overload; 462{$IFDEF HAS_SDO_BYTES} 463 function getBytes(const AIndex : PtrInt) : TSDOBytes;overload; 464{$ENDIF HAS_SDO_BYTES} 465{$IFDEF HAS_SDO_CHAR} 466 function getCharacter(const AIndex : PtrInt) : TSDOChar;overload; 467{$ENDIF HAS_SDO_CHAR} 468{$IFDEF HAS_SDO_CURRENCY} 469 function getCurrency(const AIndex : PtrInt) : TSDOCurrency;overload; 470{$ENDIF HAS_SDO_CURRENCY} 471 function getDate(const AIndex : PtrInt) : TSDODate;overload; 472{$IFDEF HAS_SDO_DOUBLE} 473 function getDouble(const AIndex : PtrInt) : TSDODouble;overload; 474{$ENDIF HAS_SDO_DOUBLE} 475{$IFDEF HAS_SDO_FLOAT} 476 function getFloat(const AIndex : PtrInt) : TSDOFloat;overload; 477{$ENDIF HAS_SDO_FLOAT} 478 function getInteger(const AIndex : PtrInt) : TSDOInteger;overload; 479{$IFDEF HAS_SDO_LONG} 480 function getLong(const AIndex : PtrInt) : TSDOLong;overload; 481{$ENDIF HAS_SDO_LONG} 482{$IFDEF HAS_SDO_SHORT} 483 function getShort(const AIndex : PtrInt) : TSDOShort;overload; 484{$ENDIF HAS_SDO_SHORT} 485 function getString(const AIndex : PtrInt) : TSDOString;overload; 486 function getDataObject(const AIndex : PtrInt) : ISDODataObject;overload; 487 function getVariant(const AIndex : PtrInt) : TSDOVariant;overload; 488 489 490 procedure setBoolean(const AIndex : PtrInt; const AValue : TSDOBoolean);overload; 491 procedure setByte(const AIndex : PtrInt; const AValue : TSDOByte);overload; 492{$IFDEF HAS_SDO_BYTES} 493 procedure setBytes(const AIndex : PtrInt; AValue : TSDOBytes);overload; 494{$ENDIF HAS_SDO_BYTES} 495{$IFDEF HAS_SDO_CHAR} 496 procedure setCharacter(const AIndex : PtrInt; const AValue : TSDOChar);overload; 497{$ENDIF HAS_SDO_CHAR} 498{$IFDEF HAS_SDO_CURRENCY} 499 procedure setCurrency(const AIndex : PtrInt; const AValue : TSDOCurrency);overload; 500{$ENDIF HAS_SDO_CURRENCY} 501 procedure setDate(const AIndex : PtrInt; const AValue : TSDODate);overload; 502{$IFDEF HAS_SDO_DOUBLE} 503 procedure setDouble(const AIndex : PtrInt; const AValue : TSDODouble);overload; 504{$ENDIF HAS_SDO_DOUBLE} 505{$IFDEF HAS_SDO_FLOAT} 506 procedure setFloat(const AIndex : PtrInt; const AValue : TSDOFloat);overload; 507{$ENDIF HAS_SDO_FLOAT} 508 procedure setInteger(const AIndex : PtrInt; const AValue : TSDOInteger);overload; 509{$IFDEF HAS_SDO_LONG} 510 procedure setLong(const AIndex : PtrInt; const AValue : TSDOLong);overload; 511{$ENDIF HAS_SDO_LONG} 512{$IFDEF HAS_SDO_SHORT} 513 procedure setShort(const AIndex : PtrInt; const AValue : TSDOShort);overload; 514{$ENDIF HAS_SDO_SHORT} 515 procedure setString(const AIndex : PtrInt; const AValue : TSDOString);overload; 516 procedure setVariant(const AIndex : PtrInt; const AValue : TSDOVariant);overload; 517 procedure setDataObject(const AIndex : PtrInt; AValue : ISDODataObject);overload; 518 519 520 procedure insert(const AIndex : PtrInt; const AValue : TSDOBoolean);overload; 521 procedure insert(const AIndex : PtrInt; const AValue : TSDOByte);overload; 522{$IFDEF HAS_SDO_BYTES} 523 procedure insertBytes(const AIndex : PtrInt; AValue : TSDOBytes);overload; 524{$ENDIF HAS_SDO_BYTES} 525{$IFDEF HAS_SDO_CHAR} 526 procedure insert(const AIndex : PtrInt; const AValue : TSDOChar);overload; 527{$ENDIF HAS_SDO_CHAR} 528{$IFDEF HAS_SDO_CURRENCY} 529 procedure insertCurrency(const AIndex : PtrInt; const AValue : TSDOCurrency); 530{$ENDIF HAS_SDO_CURRENCY} 531 procedure insert(const AIndex : PtrInt; const AValue : TSDODate);overload; 532{$IFDEF HAS_SDO_DOUBLE} 533 procedure insert(const AIndex : PtrInt; const AValue : TSDODouble);overload; 534{$ENDIF HAS_SDO_DOUBLE} 535{$IFDEF HAS_SDO_FLOAT} 536 procedure insert(const AIndex : PtrInt; const AValue : TSDOFloat);overload; 537{$ENDIF HAS_SDO_FLOAT} 538 procedure insert(const AIndex : PtrInt; const AValue : TSDOInteger);overload; 539{$IFDEF HAS_SDO_LONG} 540 procedure insert(const AIndex : PtrInt; const AValue : TSDOLong);overload; 541{$ENDIF HAS_SDO_LONG} 542{$IFDEF HAS_SDO_SHORT} 543 procedure insert(const AIndex : PtrInt; const AValue : TSDOShort);overload; 544{$ENDIF HAS_SDO_SHORT} 545 procedure insert(const AIndex : PtrInt; const AValue : TSDOString);overload; 546 procedure insert(const AIndex : PtrInt; AValue : ISDODataObject);overload; 547 548 549 procedure append(const AValue : TSDOBoolean);overload; 550 procedure append(const AValue : TSDOByte);overload; 551{$IFDEF HAS_SDO_BYTES} 552 procedure appendBytes(AValue : TSDOBytes);overload; 553{$ENDIF HAS_SDO_BYTES} 554{$IFDEF HAS_SDO_CHAR} 555 procedure append(const AValue : TSDOChar);overload; 556{$ENDIF HAS_SDO_CHAR} 557{$IFDEF HAS_SDO_CURRENCY} 558 procedure appendCurrency(const AValue : TSDOCurrency); 559{$ENDIF HAS_SDO_CURRENCY} 560 procedure append(const AValue : TSDODate);overload; 561{$IFDEF HAS_SDO_DOUBLE} 562 procedure append(const AValue : TSDODouble);overload; 563{$ENDIF HAS_SDO_DOUBLE} 564{$IFDEF HAS_SDO_FLOAT} 565 procedure append(const AValue : TSDOFloat);overload; 566{$ENDIF HAS_SDO_FLOAT} 567 procedure append(const AValue : TSDOInteger);overload; 568{$IFDEF HAS_SDO_LONG} 569 procedure append(const AValue : TSDOLong);overload; 570{$ENDIF HAS_SDO_LONG} 571{$IFDEF HAS_SDO_SHORT} 572 procedure append(const AValue : TSDOShort);overload; 573{$ENDIF HAS_SDO_SHORT} 574 procedure append(const AValue : TSDOString);overload; 575 procedure append(AValue : ISDODataObject);overload; 576 577 578 procedure delete(const AIndex : PtrInt);overload; 579 procedure delete();overload; 580 public 581 constructor Create(const AItemType : ISDOType); 582 destructor Destroy();override; 583 end; 584 585 TSDOOwnedDataObjectList = class(TSDODataObjectList,IInterface,ISDODataObjectList) 586 private 587 FOwner : Pointer; // do not add a reference count! 588 FOwnerProperty : ISDOProperty; 589 protected 590 procedure RecordChange(const AChange : TManyValuePropAction);overload;{$IFDEF USE_INLINE}inline;{$ENDIF} 591 function getOwner() : ISDODataObject;{$IFDEF USE_INLINE}inline;{$ENDIF} 592 procedure InternalSetDataObject(const AValue : ISDODataObject; const ADoRecordChange : Boolean); 593 protected 594 procedure setBoolean(const AValue : TSDOBoolean);overload; 595 procedure setByte(const AValue : TSDOByte);overload; 596{$IFDEF HAS_SDO_BYTES} 597 procedure setBytes(AValue : TSDOBytes);overload; 598{$ENDIF HAS_SDO_BYTES} 599{$IFDEF HAS_SDO_CHAR} 600 procedure setCharacter(const AValue : TSDOChar);overload; 601{$ENDIF HAS_SDO_CHAR} 602{$IFDEF HAS_SDO_CURRENCY} 603 procedure setCurrency(const AValue : TSDOCurrency);overload; 604{$ENDIF HAS_SDO_CURRENCY} 605 procedure setDate(const AValue : TSDODate);overload; 606{$IFDEF HAS_SDO_DOUBLE} 607 procedure setDouble(const AValue : TSDODouble);overload; 608{$ENDIF HAS_SDO_DOUBLE} 609{$IFDEF HAS_SDO_FLOAT} 610 procedure setFloat(const AValue : TSDOFloat);overload; 611{$ENDIF HAS_SDO_FLOAT} 612 procedure setInteger(const AValue : TSDOInteger);overload; 613{$IFDEF HAS_SDO_LONG} 614 procedure setLong(const AValue : TSDOLong);overload; 615{$ENDIF HAS_SDO_LONG} 616{$IFDEF HAS_SDO_SHORT} 617 procedure setShort(const AValue : TSDOShort);overload; 618{$ENDIF HAS_SDO_SHORT} 619 procedure setString(const AValue : TSDOString);overload; 620 procedure setDataObject(AValue : ISDODataObject);overload; 621 procedure setVariant(const AValue : TSDOVariant);overload; 622 623 procedure setBoolean(const AIndex : PtrInt; const AValue : TSDOBoolean);overload; 624 procedure setByte(const AIndex : PtrInt; const AValue : TSDOByte);overload; 625{$IFDEF HAS_SDO_BYTES} 626 procedure setBytes(const AIndex : PtrInt; AValue : TSDOBytes);overload; 627{$ENDIF HAS_SDO_BYTES} 628{$IFDEF HAS_SDO_CHAR} 629 procedure setCharacter(const AIndex : PtrInt; const AValue : TSDOChar);overload; 630{$ENDIF HAS_SDO_CHAR} 631{$IFDEF HAS_SDO_CURRENCY} 632 procedure setCurrency(const AIndex : PtrInt; const AValue : TSDOCurrency);overload; 633{$ENDIF HAS_SDO_CURRENCY} 634 procedure setDate(const AIndex : PtrInt; const AValue : TSDODate);overload; 635{$IFDEF HAS_SDO_DOUBLE} 636 procedure setDouble(const AIndex : PtrInt; const AValue : TSDODouble);overload; 637{$ENDIF HAS_SDO_DOUBLE} 638{$IFDEF HAS_SDO_FLOAT} 639 procedure setFloat(const AIndex : PtrInt; const AValue : TSDOFloat);overload; 640{$ENDIF HAS_SDO_FLOAT} 641 procedure setInteger(const AIndex : PtrInt; const AValue : TSDOInteger);overload; 642{$IFDEF HAS_SDO_LONG} 643 procedure setLong(const AIndex : PtrInt; const AValue : TSDOLong);overload; 644{$ENDIF HAS_SDO_LONG} 645{$IFDEF HAS_SDO_SHORT} 646 procedure setShort(const AIndex : PtrInt; const AValue : TSDOShort);overload; 647{$ENDIF HAS_SDO_SHORT} 648 procedure setString(const AIndex : PtrInt; const AValue : TSDOString);overload; 649 procedure setDataObject(const AIndex : PtrInt; AValue : ISDODataObject);overload; 650 procedure setVariant(const AIndex : PtrInt; const AValue : TSDOVariant);overload; 651 652 procedure insert(const AIndex : PtrInt; const AValue : TSDOBoolean);overload; 653 procedure insert(const AIndex : PtrInt; const AValue : TSDOByte);overload; 654{$IFDEF HAS_SDO_BYTES} 655 procedure insertBytes(const AIndex : PtrInt; AValue : TSDOBytes);overload; 656{$ENDIF HAS_SDO_BYTES} 657{$IFDEF HAS_SDO_CHAR} 658 procedure insert(const AIndex : PtrInt; const AValue : TSDOChar);overload; 659{$ENDIF HAS_SDO_CHAR} 660{$IFDEF HAS_SDO_CURRENCY} 661 procedure insertCurrency(const AIndex : PtrInt; const AValue : TSDOCurrency); 662{$ENDIF HAS_SDO_CURRENCY} 663 procedure insert(const AIndex : PtrInt; const AValue : TSDODate);overload; 664{$IFDEF HAS_SDO_DOUBLE} 665 procedure insert(const AIndex : PtrInt; const AValue : TSDODouble);overload; 666{$ENDIF HAS_SDO_DOUBLE} 667{$IFDEF HAS_SDO_FLOAT} 668 procedure insert(const AIndex : PtrInt; const AValue : TSDOFloat);overload; 669{$ENDIF HAS_SDO_FLOAT} 670 procedure insert(const AIndex : PtrInt; const AValue : TSDOInteger);overload; 671{$IFDEF HAS_SDO_LONG} 672 procedure insert(const AIndex : PtrInt; const AValue : TSDOLong);overload; 673{$ENDIF HAS_SDO_LONG} 674{$IFDEF HAS_SDO_SHORT} 675 procedure insert(const AIndex : PtrInt; const AValue : TSDOShort);overload; 676{$ENDIF HAS_SDO_SHORT} 677 procedure insert(const AIndex : PtrInt; const AValue : TSDOString);overload; 678 procedure insert(const AIndex : PtrInt; AValue : ISDODataObject);overload; 679 680 procedure append(const AValue : TSDOBoolean);overload; 681 procedure append(const AValue : TSDOByte);overload; 682{$IFDEF HAS_SDO_BYTES} 683 procedure appendBytes(AValue : TSDOBytes);overload; 684{$ENDIF HAS_SDO_BYTES} 685{$IFDEF HAS_SDO_CHAR} 686 procedure append(const AValue : TSDOChar);overload; 687{$ENDIF HAS_SDO_CHAR} 688{$IFDEF HAS_SDO_CURRENCY} 689 procedure appendCurrency(const AValue : TSDOCurrency); 690{$ENDIF HAS_SDO_CURRENCY} 691 procedure append(const AValue : TSDODate);overload; 692{$IFDEF HAS_SDO_DOUBLE} 693 procedure append(const AValue : TSDODouble);overload; 694{$ENDIF HAS_SDO_DOUBLE} 695{$IFDEF HAS_SDO_FLOAT} 696 procedure append(const AValue : TSDOFloat);overload; 697{$ENDIF HAS_SDO_FLOAT} 698 procedure append(const AValue : TSDOInteger);overload; 699{$IFDEF HAS_SDO_LONG} 700 procedure append(const AValue : TSDOLong);overload; 701{$ENDIF HAS_SDO_LONG} 702{$IFDEF HAS_SDO_SHORT} 703 procedure append(const AValue : TSDOShort);overload; 704{$ENDIF HAS_SDO_SHORT} 705 procedure append(AValue : ISDODataObject);overload; 706 procedure append(const AValue : TSDOString);overload; 707 708 procedure delete(const AIndex : PtrInt);overload; 709 procedure delete();overload; 710 public 711 constructor Create( 712 const AOwner : ISDODataObject; 713 const AProperty : ISDOProperty 714 ); 715 end; 716 717implementation 718 719uses 720 sdo_imp_utils, sdo_utils; 721 722{ TSDOBaseDataObject } 723 724procedure TSDOBaseDataObject.clear; 725begin 726 727end; 728 729constructor TSDOBaseDataObject.Create( 730 const AType: ISDOTypeEx; 731 const AContainer : ISDODataObject; 732 const AContainerProperty : ISDOProperty 733); 734begin 735 if ( AType = nil ) then 736 raise ESDOIllegalArgumentException.Create('AType'); 737 if ( AContainer <> nil ) and ( AContainerProperty = nil ) then 738 raise ESDOIllegalArgumentException.Create('AContainerProperty'); 739 FType := AType as ISDOObjectType; 740 FContainer := Pointer(AContainer); 741 FContainerProperty := Pointer(AContainerProperty); 742 FXPathExpression := TXPathExpression.Create(); 743 FXPathProcessor := TXPathProcessor.Create(); 744 PrepareDataBuffer(); 745 InitializeDefaultValues(); 746 FType.setUsedFlag(True); 747end; 748 749function TSDOBaseDataObject.createDataObject(const APath: string): ISDODataObject; 750var 751 locCtx : TXPathExecContext; 752begin 753 locCtx := parsePropertyPath(APath); 754 if ( locCtx.PropertyOwner = nil ) then 755 raise ESDOInvalidPathException.Create(APath); 756 Result := locCtx.PropertyOwner.createDataObject(locCtx.CurrentProperty); 757end; 758 759function TSDOBaseDataObject.createDataObject(const AProperty: ISDOProperty) : ISDODataObject; 760var 761 prp : ISDOPropertyEx; 762begin 763 if ( AProperty = nil ) or ( not Self.IsOwnerOf(AProperty) ) then 764 raise ESDOIllegalArgumentException.Create('AProperty'); 765 prp := AProperty as ISDOPropertyEx; 766 Result := TSDOBaseDataObjectClass(Self.ClassType).Create( 767 prp.getType() as ISDOTypeEx, 768 nil, //Self as ISDODataObject, 769 prp 770 ) as ISDODataObject; 771 if not AProperty.isMany() then 772 setDataObject(prp,Result); 773end; 774 775function TSDOBaseDataObject.createDataObject(const APropertyIndex: PtrUInt): ISDODataObject; 776begin 777 Result := createDataObject(getProperty(APropertyIndex)); 778end; 779 780destructor TSDOBaseDataObject.Destroy(); 781begin 782 FDestroying := True; 783 FreeBuffer(); 784 FType := nil; 785 FContainer := nil; 786 FContainerProperty := nil; 787 FChangeSummary := nil; 788 FreeAndNil(FReferenceLinkList); 789 FreeAndNil(FXPathExpression); 790 FreeAndNil(FXPathProcessor); 791 inherited; 792end; 793 794function TSDOBaseDataObject.getBoolean(const APath: string): TSDOBoolean; 795var 796 locCtx : TXPathExecContext; 797begin 798 locCtx := parsePropertyPath(APath); 799 if ( locCtx.PropertyOwner = nil ) then 800 raise ESDOInvalidPathException.Create(APath); 801 if ( locCtx.ContentKind = xckList ) then 802 Result := locCtx.ListItem.getBoolean() 803 else 804 Result := locCtx.PropertyOwner.getBoolean(locCtx.CurrentProperty); 805end; 806 807function TSDOBaseDataObject.getBoolean(const APropertyIndex: PtrUInt): TSDOBoolean; 808begin 809 Result := getBoolean(getProperty(APropertyIndex)); 810end; 811 812function TSDOBaseDataObject.getBoolean(const AProperty: ISDOProperty): TSDOBoolean; 813var 814 prp : ISDOPropertyEx; 815begin 816 if ( AProperty = nil ) or 817 ( not Self.IsOwnerOf(AProperty) ) or 818 ( AProperty.isMany() ) 819 then begin 820 raise ESDOIllegalArgumentException.Create('AProperty'); 821 end; 822 prp := AProperty as ISDOPropertyEx; 823 Result := getField(prp.getTypeEnum()).getBoolean(FBuffer,prp.getBufferOffset()); 824end; 825 826function TSDOBaseDataObject.getByte(const APath: string): TSDOByte; 827var 828 locCtx : TXPathExecContext; 829begin 830 locCtx := parsePropertyPath(APath); 831 if ( locCtx.PropertyOwner = nil ) then 832 raise ESDOInvalidPathException.Create(APath); 833 if ( locCtx.ContentKind = xckList ) then 834 Result := locCtx.ListItem.getByte() 835 else 836 Result := locCtx.PropertyOwner.getByte(locCtx.CurrentProperty); 837end; 838 839function TSDOBaseDataObject.getByte(const APropertyIndex: PtrUInt): TSDOByte; 840begin 841 Result := getByte(getProperty(APropertyIndex)); 842end; 843 844function TSDOBaseDataObject.getByte(const AProperty: ISDOProperty): TSDOByte; 845var 846 prp : ISDOPropertyEx; 847begin 848 if ( AProperty = nil ) or 849 ( not Self.IsOwnerOf(AProperty) ) or 850 ( AProperty.isMany() ) 851 then begin 852 raise ESDOIllegalArgumentException.Create('AProperty'); 853 end; 854 prp := AProperty as ISDOPropertyEx; 855 Result := getField(prp.getTypeEnum()).getByte(FBuffer,prp.getBufferOffset()); 856end; 857 858{$IFDEF HAS_SDO_BYTES} 859function TSDOBaseDataObject.getBytes(const AProperty: ISDOProperty): TSDOBytes; 860var 861 prp : ISDOPropertyEx; 862begin 863 if ( AProperty = nil ) or 864 ( not Self.IsOwnerOf(AProperty) ) or 865 ( AProperty.isMany() ) 866 then begin 867 raise ESDOIllegalArgumentException.Create('AProperty'); 868 end; 869 prp := AProperty as ISDOPropertyEx; 870 Result := getField(prp.getTypeEnum()).getBytes(FBuffer,prp.getBufferOffset()); 871end; 872 873function TSDOBaseDataObject.getBytes(const APath: string): TSDOBytes; 874var 875 locCtx : TXPathExecContext; 876begin 877 locCtx := parsePropertyPath(APath); 878 if ( locCtx.PropertyOwner = nil ) then 879 raise ESDOInvalidPathException.Create(APath); 880 if ( locCtx.ContentKind = xckList ) then 881 Result := locCtx.ListItem.getBytes() 882 else 883 Result := locCtx.PropertyOwner.getBytes(locCtx.CurrentProperty); 884end; 885 886function TSDOBaseDataObject.getBytes(const APropertyIndex: PtrUInt): TSDOBytes; 887begin 888 Result := getBytes(getProperty(APropertyIndex)); 889end; 890{$ENDIF HAS_SDO_BYTES} 891 892function TSDOBaseDataObject.getCharacter(const AProperty: ISDOProperty): TSDOChar; 893var 894 prp : ISDOPropertyEx; 895begin 896 if ( AProperty = nil ) or 897 ( not Self.IsOwnerOf(AProperty) ) or 898 ( AProperty.isMany() ) 899 then begin 900 raise ESDOIllegalArgumentException.Create('AProperty'); 901 end; 902 prp := AProperty as ISDOPropertyEx; 903 Result := getField(prp.getTypeEnum()).getCharacter(FBuffer,prp.getBufferOffset()); 904end; 905 906function TSDOBaseDataObject.getCharacter(const APropertyIndex: PtrUInt): TSDOChar; 907begin 908 Result := getCharacter(getProperty(APropertyIndex)); 909end; 910 911function TSDOBaseDataObject.getCharacter(const APath: string): TSDOChar; 912var 913 locCtx : TXPathExecContext; 914begin 915 locCtx := parsePropertyPath(APath); 916 if ( locCtx.PropertyOwner = nil ) then 917 raise ESDOInvalidPathException.Create(APath); 918 if ( locCtx.ContentKind = xckList ) then 919 Result := locCtx.ListItem.getCharacter() 920 else 921 Result := locCtx.PropertyOwner.getCharacter(locCtx.CurrentProperty); 922end; 923 924function TSDOBaseDataObject.getContainer() : ISDODataObject; 925begin 926 Result := ISDODataObject(FContainer); 927end; 928 929function TSDOBaseDataObject.getContainmentProperty() : ISDOProperty; 930begin 931 if not Assigned(FContainerProperty) then 932 raise ESDOPropertyNotFoundException.Create('ContainmentProperty'); 933 Result := ISDOProperty(FContainerProperty); 934end; 935 936{$IFDEF HAS_SDO_CURRENCY } 937function TSDOBaseDataObject.getCurrency(const AProperty: ISDOProperty): TSDOCurrency; 938var 939 prp : ISDOPropertyEx; 940begin 941 if ( AProperty = nil ) or 942 ( not Self.IsOwnerOf(AProperty) ) or 943 ( AProperty.isMany() ) 944 then begin 945 raise ESDOIllegalArgumentException.Create('AProperty'); 946 end; 947 prp := AProperty as ISDOPropertyEx; 948 Result := getField(prp.getTypeEnum()).getCurrency(FBuffer,prp.getBufferOffset()); 949end; 950 951function TSDOBaseDataObject.getCurrency(const APropertyIndex: PtrUInt): TSDOCurrency; 952begin 953 Result := getCurrency(getProperty(APropertyIndex)); 954end; 955 956function TSDOBaseDataObject.getCurrency(const APath: string): TSDOCurrency; 957var 958 locCtx : TXPathExecContext; 959begin 960 locCtx := parsePropertyPath(APath); 961 if ( locCtx.PropertyOwner = nil ) then 962 raise ESDOInvalidPathException.Create(APath); 963 if ( locCtx.ContentKind = xckList ) then 964 Result := locCtx.ListItem.getCurrency() 965 else 966 Result := locCtx.PropertyOwner.getCurrency(locCtx.CurrentProperty); 967end; 968{$ENDIF HAS_SDO_CURRENCY } 969 970function TSDOBaseDataObject.getDataObject(const APath: string): ISDODataObject; 971var 972 locCtx : TXPathExecContext; 973begin 974 locCtx := parsePropertyPath(APath); 975 if ( locCtx.PropertyOwner = nil ) then 976 raise ESDOInvalidPathException.Create(APath); 977 Result := locCtx.ObjectItem; 978 {if ( locCtx.ContentKind = xckList ) then 979 Result := locCtx.ListItem.getDataObject() 980 else 981 Result := locCtx.PropertyOwner.getDataObject(locCtx.CurrentProperty);} 982end; 983 984function TSDOBaseDataObject.getDataObject(const APropertyIndex: PtrUInt): ISDODataObject; 985begin 986 Result := getDataObject(getProperty(APropertyIndex)); 987end; 988 989function TSDOBaseDataObject.getDataObject(const AProperty: ISDOProperty): ISDODataObject; 990var 991 prp : ISDOPropertyEx; 992begin 993 if ( AProperty = nil ) or ( not Self.IsOwnerOf(AProperty) ) then 994 raise ESDOIllegalArgumentException.Create('AProperty'); 995 if AProperty.isMany() then begin 996 Result := getList(AProperty).getDataObject(); 997 end else begin 998 prp := AProperty as ISDOPropertyEx; 999 Result := getField(prp.getTypeEnum()).getDataObject(FBuffer,prp.getBufferOffset()); 1000 end; 1001end; 1002 1003function TSDOBaseDataObject.getDate(const APropertyIndex: PtrUInt): TSDODate; 1004begin 1005 Result := getDate(getProperty(APropertyIndex)); 1006end; 1007 1008function TSDOBaseDataObject.getDate(const APath: string): TSDODate; 1009var 1010 locCtx : TXPathExecContext; 1011begin 1012 locCtx := parsePropertyPath(APath); 1013 if ( locCtx.PropertyOwner = nil ) then 1014 raise ESDOInvalidPathException.Create(APath); 1015 if ( locCtx.ContentKind = xckList ) then 1016 Result := locCtx.ListItem.getDate() 1017 else 1018 Result := locCtx.PropertyOwner.getDate(locCtx.CurrentProperty); 1019end; 1020 1021function TSDOBaseDataObject.getDate(const AProperty: ISDOProperty): TSDODate; 1022var 1023 prp : ISDOPropertyEx; 1024begin 1025 if ( AProperty = nil ) or 1026 ( not Self.IsOwnerOf(AProperty) ) or 1027 ( AProperty.isMany() ) 1028 then begin 1029 raise ESDOIllegalArgumentException.Create('AProperty'); 1030 end; 1031 prp := AProperty as ISDOPropertyEx; 1032 Result := getField(prp.getTypeEnum()).getDate(FBuffer,prp.getBufferOffset()); 1033end; 1034 1035{$IFDEF HAS_SDO_DOUBLE } 1036function TSDOBaseDataObject.getDouble(const AProperty: ISDOProperty): TSDODouble; 1037var 1038 prp : ISDOPropertyEx; 1039begin 1040 if ( AProperty = nil ) or 1041 ( not Self.IsOwnerOf(AProperty) ) or 1042 ( AProperty.isMany() ) 1043 then begin 1044 raise ESDOIllegalArgumentException.Create('AProperty'); 1045 end; 1046 prp := AProperty as ISDOPropertyEx; 1047 Result := getField(prp.getTypeEnum()).getDouble(FBuffer,prp.getBufferOffset()); 1048end; 1049 1050function TSDOBaseDataObject.getDouble(const APropertyIndex: PtrUInt): TSDODouble; 1051begin 1052 Result := getDouble(getProperty(APropertyIndex)); 1053end; 1054 1055function TSDOBaseDataObject.getDouble(const APath: string): TSDODouble; 1056var 1057 locCtx : TXPathExecContext; 1058begin 1059 locCtx := parsePropertyPath(APath); 1060 if ( locCtx.PropertyOwner = nil ) then 1061 raise ESDOInvalidPathException.Create(APath); 1062 if ( locCtx.ContentKind = xckList ) then 1063 Result := locCtx.ListItem.getDouble() 1064 else 1065 Result := locCtx.PropertyOwner.getDouble(locCtx.CurrentProperty); 1066end; 1067{$ENDIF HAS_SDO_DOUBLE } 1068 1069{$IFDEF HAS_SDO_FLOAT } 1070function TSDOBaseDataObject.getFloat(const AProperty: ISDOProperty): TSDOFloat; 1071var 1072 prp : ISDOPropertyEx; 1073begin 1074 if ( AProperty = nil ) or 1075 ( not Self.IsOwnerOf(AProperty) ) or 1076 ( AProperty.isMany() ) 1077 then begin 1078 raise ESDOIllegalArgumentException.Create('AProperty'); 1079 end; 1080 prp := AProperty as ISDOPropertyEx; 1081 Result := getField(prp.getTypeEnum()).getFloat(FBuffer,prp.getBufferOffset()); 1082end; 1083 1084function TSDOBaseDataObject.getFloat(const APropertyIndex: PtrUInt): TSDOFloat; 1085begin 1086 Result := getFloat(getProperty(APropertyIndex)); 1087end; 1088 1089function TSDOBaseDataObject.getFloat(const APath: string): TSDOFloat; 1090var 1091 locCtx : TXPathExecContext; 1092begin 1093 locCtx := parsePropertyPath(APath); 1094 if ( locCtx.PropertyOwner = nil ) then 1095 raise ESDOInvalidPathException.Create(APath); 1096 if ( locCtx.ContentKind = xckList ) then 1097 Result := locCtx.ListItem.getFloat() 1098 else 1099 Result := locCtx.PropertyOwner.getFloat(locCtx.CurrentProperty); 1100end; 1101{$ENDIF HAS_SDO_FLOAT } 1102 1103function TSDOBaseDataObject.getInstanceProperties() : ISDOPropertyList; 1104begin 1105 Result := FType.getProperties(); 1106end; 1107 1108function TSDOBaseDataObject.getInteger(const AProperty: ISDOProperty): TSDOInteger; 1109var 1110 prp : ISDOPropertyEx; 1111begin 1112 if ( AProperty = nil ) or 1113 ( not Self.IsOwnerOf(AProperty) ) or 1114 ( AProperty.isMany() ) 1115 then begin 1116 raise ESDOIllegalArgumentException.Create('AProperty'); 1117 end; 1118 prp := AProperty as ISDOPropertyEx; 1119 Result := getField(prp.getTypeEnum()).getInteger(FBuffer,prp.getBufferOffset()); 1120end; 1121 1122function TSDOBaseDataObject.getInteger(const APropertyIndex: PtrUInt): TSDOInteger; 1123begin 1124 Result := getInteger(getProperty(APropertyIndex)); 1125end; 1126 1127function TSDOBaseDataObject.getInteger(const APath: string): TSDOInteger; 1128var 1129 locCtx : TXPathExecContext; 1130begin 1131 locCtx := parsePropertyPath(APath); 1132 if ( locCtx.PropertyOwner = nil ) then 1133 raise ESDOInvalidPathException.Create(APath); 1134 if ( locCtx.ContentKind = xckList ) then 1135 Result := locCtx.ListItem.getInteger() 1136 else 1137 Result := locCtx.PropertyOwner.getInteger(locCtx.CurrentProperty); 1138end; 1139 1140function TSDOBaseDataObject.getLong(const AProperty: ISDOProperty): TSDOLong; 1141var 1142 prp : ISDOPropertyEx; 1143begin 1144 if ( AProperty = nil ) or 1145 ( not Self.IsOwnerOf(AProperty) ) or 1146 ( AProperty.isMany() ) 1147 then begin 1148 raise ESDOIllegalArgumentException.Create('AProperty'); 1149 end; 1150 prp := AProperty as ISDOPropertyEx; 1151 Result := getField(prp.getTypeEnum()).getLong(FBuffer,prp.getBufferOffset()); 1152end; 1153 1154function TSDOBaseDataObject.getLong(const APropertyIndex: PtrUInt): TSDOLong; 1155begin 1156 Result := getLong(getProperty(APropertyIndex)); 1157end; 1158 1159function TSDOBaseDataObject.getLong(const APath: string): TSDOLong; 1160var 1161 locCtx : TXPathExecContext; 1162begin 1163 locCtx := parsePropertyPath(APath); 1164 if ( locCtx.PropertyOwner = nil ) then 1165 raise ESDOInvalidPathException.Create(APath); 1166 if ( locCtx.ContentKind = xckList ) then 1167 Result := locCtx.ListItem.getLong() 1168 else 1169 Result := locCtx.PropertyOwner.getLong(locCtx.CurrentProperty); 1170end; 1171 1172function TSDOBaseDataObject.getProperty(const AIndex: PtrUInt): ISDOProperty; 1173begin 1174 Result := getInstanceProperties().getItem(AIndex);//FType.getProperty(AIndex); 1175end; 1176 1177function TSDOBaseDataObject.getProperty(const AProp: string): ISDOProperty; 1178begin 1179 Result := getInstanceProperties().find(AProp); 1180 if ( Result = nil ) then 1181 raise ESDOPropertyNotFoundException.Create(AProp); 1182end; 1183 1184function TSDOBaseDataObject.getPropertyIndex(const AProperty: ISDOProperty): PtrInt; 1185begin 1186 Result := FType.getPropertyIndex(AProperty.getName()); 1187end; 1188 1189function TSDOBaseDataObject.getShort(const APropertyIndex: PtrUInt): TSDOShort; 1190begin 1191 Result := getShort(getProperty(APropertyIndex)); 1192end; 1193 1194function TSDOBaseDataObject.getShort(const APath: string): TSDOShort; 1195var 1196 locCtx : TXPathExecContext; 1197begin 1198 locCtx := parsePropertyPath(APath); 1199 if ( locCtx.PropertyOwner = nil ) then 1200 raise ESDOInvalidPathException.Create(APath); 1201 if ( locCtx.ContentKind = xckList ) then 1202 Result := locCtx.ListItem.getShort() 1203 else 1204 Result := locCtx.PropertyOwner.getShort(locCtx.CurrentProperty); 1205end; 1206 1207function TSDOBaseDataObject.getShort(const AProperty: ISDOProperty): TSDOShort; 1208var 1209 prp : ISDOPropertyEx; 1210begin 1211 if ( AProperty = nil ) or 1212 ( not Self.IsOwnerOf(AProperty) ) or 1213 ( AProperty.isMany() ) 1214 then begin 1215 raise ESDOIllegalArgumentException.Create('AProperty'); 1216 end; 1217 prp := AProperty as ISDOPropertyEx; 1218 Result := getField(prp.getTypeEnum()).getShort(FBuffer,prp.getBufferOffset()); 1219end; 1220 1221function TSDOBaseDataObject.getString(const AProperty: ISDOProperty): TSDOString; 1222var 1223 prp : ISDOPropertyEx; 1224begin 1225 if ( AProperty = nil ) or 1226 ( not Self.IsOwnerOf(AProperty) ) or 1227 ( AProperty.isMany() ) 1228 then begin 1229 raise ESDOIllegalArgumentException.Create('AProperty'); 1230 end; 1231 prp := AProperty as ISDOPropertyEx; 1232 Result := getField(prp.getTypeEnum()).getString(FBuffer,prp.getBufferOffset()); 1233end; 1234 1235function TSDOBaseDataObject.getString(const APropertyIndex: PtrUInt): TSDOString; 1236begin 1237 Result := getString(getProperty(APropertyIndex)); 1238end; 1239 1240function TSDOBaseDataObject.getString(const APath: string): TSDOString; 1241var 1242 locCtx : TXPathExecContext; 1243begin 1244 locCtx := parsePropertyPath(APath); 1245 if ( locCtx.PropertyOwner = nil ) then 1246 raise ESDOInvalidPathException.Create(APath); 1247 if ( locCtx.ContentKind = xckList ) then 1248 Result := locCtx.ListItem.getString() 1249 else 1250 Result := locCtx.PropertyOwner.getString(locCtx.CurrentProperty); 1251end; 1252 1253function TSDOBaseDataObject.getType() : ISDOType; 1254begin 1255 Result := FType as ISDOType; 1256end; 1257 1258function TSDOBaseDataObject.getTypeEnum() : TSDOTypeKind; 1259begin 1260 Result := FType.getTypeEnum(); 1261end; 1262 1263function TSDOBaseDataObject.isNull(const APath: string): Boolean; 1264var 1265 locCtx : TXPathExecContext; 1266begin 1267 locCtx := parsePropertyPath(APath); 1268 if ( locCtx.PropertyOwner = nil ) then 1269 raise ESDOInvalidPathException.Create(APath); 1270 case locCtx.ContentKind of 1271 xckNull : Result := True; 1272 xckObject : Result := False; 1273 xckList : 1274 begin 1275 Result := locCtx.CurrentProperty.getType().isDataObjectType and ( locCtx.ListItem.getDataObject() = nil ); 1276 end; 1277 xckValue : Result := locCtx.ObjectItem.isNull(locCtx.CurrentProperty); 1278 else 1279 Result := False; 1280 end; 1281end; 1282 1283function TSDOBaseDataObject.isNull(const AProperty: ISDOProperty): Boolean; 1284var 1285 prp : ISDOPropertyEx; 1286begin 1287 if ( AProperty = nil ) or ( not Self.IsOwnerOf(AProperty) ) then 1288 raise ESDOIllegalArgumentException.Create('AProperty'); 1289 if AProperty.isMany() then begin 1290 Result := ( getList(AProperty).size > 0 ); 1291 end else begin 1292 prp := AProperty as ISDOPropertyEx; 1293 Result := getField(prp.getTypeEnum()).isNull(FBuffer,prp.getBufferOffset()); 1294 end; 1295end; 1296 1297function TSDOBaseDataObject.isNull(const APropertyIndex: PtrUInt): Boolean; 1298begin 1299 Result := isNull(getProperty(APropertyIndex)); 1300end; 1301 1302function TSDOBaseDataObject.isSet(const APropertyIndex: PtrUInt): Boolean; 1303begin 1304 Result := isSet(getProperty(APropertyIndex)); 1305end; 1306 1307function TSDOBaseDataObject.isSet(const APath: string): Boolean; 1308var 1309 locCtx : TXPathExecContext; 1310begin 1311 locCtx := parsePropertyPath(APath); 1312 if ( locCtx.PropertyOwner = nil ) then 1313 raise ESDOInvalidPathException.Create(APath); 1314 case locCtx.ContentKind of 1315 xckNull : Result := not locCtx.PropertyOwner.getType().isDataObjectType(); 1316 xckObject : Result := locCtx.PropertyOwner.isSet(locCtx.CurrentProperty); 1317 xckList : Result := ( locCtx.ListItem.size() > 0 ); 1318 xckValue : Result := locCtx.ObjectItem.isSet(locCtx.CurrentProperty); 1319 else 1320 Result := False; 1321 end; 1322end; 1323 1324function TSDOBaseDataObject.isSet(const AProperty: ISDOProperty): Boolean; 1325var 1326 prp : ISDOPropertyEx; 1327begin 1328 if ( AProperty = nil ) or ( not Self.IsOwnerOf(AProperty) ) then 1329 raise ESDOIllegalArgumentException.Create('AProperty'); 1330 if AProperty.isMany() then begin 1331 Result := ( getList(AP…
Large files files are truncated, but you can click here to view the full file