/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

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