home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 February / PCWorld_2000-02_cd.bin / Software / TemaCD / tcvpa / data1.cab / MyFileGroup / INCLUDE / CppBind.hpp < prev    next >
C/C++ Source or Header  |  1999-06-03  |  15KB  |  449 lines

  1. #ifndef _INC_CPPBIND_HPP
  2. #define _INC_CPPBIND_HPP
  3. class TC_CPsClassMgr;
  4. class TC_CPsCollectMgr;
  5.  
  6. class TC_CPsBuffer;
  7. class TC_CPsObject;
  8. class TC_CPsClassInfo;
  9. class TC_CPsAttribInfo;
  10.  
  11. template <class T> class TC_TPsClass;
  12. template <class T> class TC_TPsAttribute;
  13.  
  14. class TC_CPsCollection;
  15. template <class T> class TC_TPsArray;
  16. template <class T> class TC_TPsSortedArray;
  17.  
  18. class TC_CPsAttribUIData;
  19. typedef TC_TPsClass<TC_CPsObject>    TCPsClass;
  20. typedef TC_TPsAttribute<TC_CPsObject>    TCPsAttribute;
  21. typedef void *(*TCPsCastFunc)(void *);
  22. typedef void *(TC_CPsObject::*PtrGetMethod)(void);
  23. typedef void (TC_CPsObject::*PtrSetMethod)(void*);
  24. typedef TCPsClass* TCPsHClass;
  25. typedef TCPsAttribute* TCPsHAttrib;
  26. typedef TC_TArrayPTR <TCPsClass> TCPsHClassCollect;
  27. TC_CPsCollection * tcPsGetCollection (char * name)  ;
  28. TCPsHClass tcPsGetClass (ULONG cid)  ;
  29. TCPsHClass tcPsGetClass (char * name)  ;
  30. #define    TC_PS_AT_UNDEF        0
  31. #define    TC_PS_AT_SHORT        1
  32. #define    TC_PS_AT_USHORT        2
  33. #define    TC_PS_AT_LONG        3
  34. #define    TC_PS_AT_ULONG        4
  35. #define    TC_PS_AT_FLOAT        5
  36. #define    TC_PS_AT_DOUBLE        6
  37. #define    TC_PS_AT_BOOL        7
  38. #define    TC_PS_AT_BYTE        8
  39. #define    TC_PS_AT_CHARARR    9
  40. #define    TC_PS_AT_STRING        10
  41. #define    TC_PS_AT_DATE        11
  42. #define    TC_PS_AT_TIME        12
  43. #define    TC_PS_AT_BCD        13
  44. #define TC_PS_AT_BINARY        14
  45. #define TC_PS_AT_BLOB        15
  46. #define    TC_PS_AT_OBJECT        16
  47. #define    TC_PS_AT_MAX        17
  48. #define TC_PS_AF_OBJECT            0x00000001L
  49. #define TC_PS_AF_COLLECTION        0x00000002L
  50. #define TC_PS_AF_OPTIONAL        0x00000004L
  51. #define TC_PS_AF_DEMANDREF        0x00000008L
  52. #define TC_PS_AF_DEPENDENT        0x00000010L
  53. #define TC_PS_AF_TRANSIENT        0x00000020L
  54. #define TC_PS_CF_TABLE            0x00000001L
  55. #define TC_PS_CF_COLLECTION        0x00000002L
  56. #define TC_PS_CF_TRANSIENT        0x00000004L
  57. enum TCPsClassScope {
  58.  ClassScope_Proper,
  59.  ClassScope_Domain,
  60. };
  61. #define    TC_PS_PRLEN_UNDEF        0
  62. #define    TC_PS_PRLEN_SHORT        6
  63. #define    TC_PS_PRLEN_LONG        11
  64. #define    TC_PS_PRLEN_FLOAT        20
  65. #define    TC_PS_PRLEN_DOUBLE        20
  66. #define    TC_PS_PRLEN_BOOL        11
  67. #define    TC_PS_PRLEN_BYTE        3
  68. #define    TC_PS_PRLEN_CHARARR        256    // max
  69. #define    TC_PS_PRLEN_STRING        256    // max
  70. #define    TC_PS_PRLEN_DATE        27
  71. #define    TC_PS_PRLEN_TIME        27
  72. #define    TC_PS_PRLEN_OBJECT        TC_PS_PRLEN_LONG    // OID
  73.  
  74. // **********************************************************************
  75. class TC_PS_EXPORT TC_CPsClassMgr 
  76. {
  77. public:   TC_CPsClassMgr ()  ;
  78. public:  static  TC_TArrayPTR<TCPsClass> m_Classes ;
  79. public: static BOOL IsRegistered (ULONG cid, const char * name)  ;
  80. public: static void Register (TCPsHClass cl)  ;
  81. public: static void UnregisterAll ()  ;
  82. public: static TCPsHClass GetClass (ULONG cid)  ;
  83. public: static TCPsHClass GetClass (const  char * name )  ;
  84. public: static void GetBaseClasses (TCPsHClassCollect & cl_cltn)  ;
  85. public: static TCPsRetCode CheckIntegrity () TC_PS_THROW_FUNC ;
  86.  
  87. }; // end of class TC_CPsClassMgr
  88.  
  89. // **********************************************************************
  90.  
  91. // **********************************************************************
  92. class TC_PS_EXPORT TC_CPsCollectMgr 
  93. {
  94.  
  95. // **********************************************************************
  96. public: 
  97. class TC_PS_EXPORT PsCltn 
  98. {
  99. public:  TC_CPsCollection * m_Cltn ;
  100. public:  char * m_Name ;
  101. public:   PsCltn (TC_CPsCollection * cltn, const char * name)  ;
  102.  
  103. }; // end of class PsCltn
  104.  
  105. // **********************************************************************
  106. public:
  107.     typedef TC_TArrayPTR <PsCltn> PsCltns;
  108. public:  static  TC_CPsCollectMgr::PsCltns m_Cltns ;
  109. public:   TC_CPsCollectMgr ()  ;
  110. public: static BOOL IsRegistered (const char * name)  ;
  111. public: static void Register (TC_CPsCollection * cltn, const char * name)  ;
  112. public: static void UnregisterAll ()  ;
  113. public: static TC_CPsCollection * GetCollection (const char * name)  ;
  114. public: static char * GetName (TC_CPsCollection * cltn)  ;
  115.  
  116. }; // end of class TC_CPsCollectMgr
  117.  
  118. // **********************************************************************
  119. // Name alterability of class and attributes fields
  120. #define    m_hClassInCltn    m_cid        // TC_TPsClass::m_cid
  121. #define    m_hRelClass        m_Type        // TC_TPsAttribute::m_Type
  122. #define m_FKNameForCltn    m_ColName    // TC_TPsAttribute::m_ColName    
  123.  
  124. // **********************************************************************
  125. class TC_PS_EXPORT TC_CPsBuffer 
  126.     : public TC_CBuffer
  127. {
  128. public:   TC_CPsBuffer ()  ;
  129. public:   TC_CPsBuffer (short val) 
  130. : TC_CBuffer(val)
  131. {
  132. } // end of func
  133. // **********************************************************************
  134.  
  135. public:   TC_CPsBuffer (unsigned short val) 
  136. : TC_CBuffer(val)
  137. {
  138. } // end of func
  139. // **********************************************************************
  140.  
  141. public:   TC_CPsBuffer (int val) 
  142. : TC_CBuffer(val)
  143. {
  144. } // end of func
  145. // **********************************************************************
  146.  
  147. public:   TC_CPsBuffer (unsigned int val) 
  148. : TC_CBuffer(val)
  149. {
  150. } // end of func
  151. // **********************************************************************
  152.  
  153. public:   TC_CPsBuffer (long val) 
  154. : TC_CBuffer(val)
  155. {
  156. } // end of func
  157. // **********************************************************************
  158.  
  159. public:   TC_CPsBuffer (unsigned long val) 
  160. : TC_CBuffer(val)
  161. {
  162. } // end of func
  163. // **********************************************************************
  164.  
  165. public:   TC_CPsBuffer (TC_CDate & dt) 
  166. : TC_CBuffer(dt)
  167. {
  168. } // end of func
  169. // **********************************************************************
  170.  
  171. public:   TC_CPsBuffer (TC_CTime & tm) 
  172. : TC_CBuffer(tm)
  173. {
  174. } // end of func
  175. // **********************************************************************
  176.  
  177. public:   TC_CPsBuffer (char val) 
  178. : TC_CBuffer(val)
  179. {
  180. } // end of func
  181. // **********************************************************************
  182.  
  183. public:   TC_CPsBuffer (unsigned char val) 
  184. : TC_CBuffer(val)
  185. {
  186. } // end of func
  187. // **********************************************************************
  188.  
  189. public:   TC_CPsBuffer (float val) 
  190. : TC_CBuffer(val)
  191. {
  192. } // end of func
  193. // **********************************************************************
  194.  
  195. public:   TC_CPsBuffer (double val) 
  196. : TC_CBuffer(val)
  197. {
  198. } // end of func
  199. // **********************************************************************
  200.  
  201. public:   TC_CPsBuffer (const char * val) 
  202. : TC_CBuffer(val)
  203. {
  204. } // end of func
  205. // **********************************************************************
  206.  
  207. public:   TC_CPsBuffer (TC_CString &val) 
  208. : TC_CBuffer(val)
  209. {
  210. } // end of func
  211. // **********************************************************************
  212.  
  213. public:   TC_CPsBuffer (TC_CBCD & bcd) 
  214. : TC_CBuffer(bcd)
  215. {
  216. } // end of func
  217. // **********************************************************************
  218.  
  219. public:   TC_CPsBuffer (const unsigned char * val, int size)  ;
  220. public:   TC_CPsBuffer (TC_CPsBuffer &val)  ;
  221. public:   TC_CPsBuffer (TC_CPsObject * obj, TC_CPsAttribInfo & atInfo)  ;
  222. public:  TC_CPsBuffer & operator = (const TC_CPsBuffer & psbuf)  ;
  223. public:  int operator == (TC_CPsBuffer & ps_buf)  ;
  224. public: virtual void GetStr (TC_CString & str)  ;
  225.  
  226. }; // end of class TC_CPsBuffer
  227.  
  228. // **********************************************************************
  229.  
  230. // **********************************************************************
  231.  template <class T>
  232. class TC_TPsClass 
  233. {
  234. public:  char * m_Name ;
  235. public:  char * m_TblName ;
  236. public:  long m_cid ;
  237. public:  long m_Flags ;
  238. public:  T*(* m_CreateObj )(void);
  239. public:  void (* m_DeleteObj )(T*);
  240. public:  int m_AttribCount ;
  241. public:  TC_TPsAttribute<T>* m_Attributes ;
  242. public:  int m_DescCount ;
  243. public:  TCPsClass ** m_Descendants ;
  244. public:  TCPsClass* m_Ancestor ;
  245. public:  TCPsCastFunc m_CastFunc ;
  246. public:  char * m_Label ;
  247. public:  long m_UserFlags ;
  248. public:  void * m_UserData ;
  249.  
  250. }; // end of class TC_TPsClass
  251.  
  252. // **********************************************************************
  253.  
  254. // **********************************************************************
  255.  template <class T>
  256. class TC_TPsAttribute 
  257. {
  258. public:  char * m_Name ;
  259. public:  char * m_ColName ;
  260. public:  long m_Type ;
  261. public:  long m_Flags ;
  262. public:  long m_Size ;
  263. public:  void (T::* m_GetMethod )();
  264. public:  void (T::* m_SetMethod )();
  265. public:  char * m_Label ;
  266. public:  TC_CPsAttribUIData * m_UIData ;
  267. public:  long m_UserFlags ;
  268. public:  void * m_UserData ;
  269. public:  void Set (TC_CPsObject * obj, void * data)  ;
  270. public:  void * Get (TC_CPsObject * obj, ULONG opt=0)  ;
  271.  
  272. }; // end of class TC_TPsAttribute
  273.  
  274. // **********************************************************************
  275.  
  276. // **********************************************************************
  277. class TC_PS_EXPORT TC_CPsClassInfo 
  278. {
  279. private:  TCPsHClass m_hClass ;
  280. public:   TC_CPsClassInfo (TCPsHClass cl)  ;
  281. public:   TC_CPsClassInfo (ULONG cid)  ;
  282. public:  BOOL IsValid ()  ;
  283. public:   operator TCPsHClass ()  ;
  284. public:  TCPsHClass HClass ()  ;
  285. public:  char * Name ()  ;
  286. public:  char * Label ()  ;
  287. public:  ULONG GetCID ()  ;
  288. public:  BOOL IsDerivedFrom (TCPsHClass hClass)  ;
  289. public:  BOOL IsAncestorOf (TCPsHClass hClass)  ;
  290. public:  BOOL IsInstance (TC_CPsObject * obj)  ;
  291. public:  BOOL IsTransient ()  ;
  292. public:  TC_CPsClassInfo GetAncestor ()  ;
  293. public:  BOOL HasAncestor ()  ;
  294. public:  BOOL HasDescendants ()  ;
  295. private:  void GetNextDescs (TCPsHClass hClass, TCPsHClassCollect & class_collect)  ;
  296. public:  BOOL GetAllDescendants (TCPsHClassCollect & class_collect)  ;
  297. public:  TC_CPsClassInfo GetBase ()  ;
  298. public:  BOOL IsBase ()  ;
  299. public:  BOOL IsAlone ()  ;
  300. public:  BOOL IsA (TC_CPsObject * obj)  ;
  301. public:  BOOL IsA (TCPsHClass hClass)  ;
  302. public:  BOOL IsCollectionClass ()  ;
  303. public:  TC_CPsClassInfo GetClassInCltn ()  ;
  304. public:  int AttribCount ()  ;
  305. public:  BOOL HasRelated (TCPsClassScope cl_scope = ClassScope_Proper)  ;
  306. public:  BOOL HasDependents (TCPsClassScope cl_scope = ClassScope_Proper)  ;
  307. public:  TC_CPsAttribInfo GetAttribInfo (int idx)  ;
  308. public:  TC_CPsAttribInfo GetAttribInfo (const char * name, TCPsClassScope cl_scope = ClassScope_Proper)  ;
  309. public:  TC_CPsAttribInfo GetFKForCltnAttrib (TC_CPsAttribInfo &atInfoCltn, TCPsClassScope cl_scope)  ;
  310. public:  TC_CPsClassInfo GetClassOfAttrib (TCPsHAttrib hAttrib)  ;
  311. public:  int operator == (TC_CPsClassInfo & clInfo)  ;
  312. public:  int operator == (TCPsHClass hClass)  ;
  313. public:  TC_CPsAttribInfo operator [] (int idx)  ;
  314. public:  void * UserData ()  ;
  315.  
  316. }; // end of class TC_CPsClassInfo
  317.  
  318. // **********************************************************************
  319.  
  320. // **********************************************************************
  321. class TC_PS_EXPORT TC_CPsAttribInfo 
  322. {
  323. private:  TCPsHClass m_hClass ;
  324. private:  TCPsHAttrib m_hAttrib ;
  325. public:   TC_CPsAttribInfo (TCPsHClass hClass, TCPsHAttrib hAttrib) 
  326. {
  327. m_hClass = hClass;
  328. m_hAttrib = hAttrib;
  329. } // end of func
  330. // **********************************************************************
  331.  
  332. public:   TC_CPsAttribInfo () 
  333. {
  334. m_hClass = 0;
  335. m_hAttrib = 0;
  336. } // end of func
  337. // **********************************************************************
  338.  
  339. public:  BOOL IsValid () 
  340. {
  341. return (m_hAttrib != 0);
  342. } // end of func
  343. // **********************************************************************
  344.  
  345. public:  int operator == (TC_CPsAttribInfo &atInfo)  ;
  346. public:   operator BOOL () 
  347. {
  348. return IsValid();
  349. } // end of func
  350. // **********************************************************************
  351.  
  352. public:   operator TCPsHAttrib () 
  353. {
  354. return m_hAttrib;
  355. } // end of func
  356. // **********************************************************************
  357.  
  358. public:  TCPsHAttrib operator -> () 
  359. {
  360. return m_hAttrib;
  361. } // end of func
  362. // **********************************************************************
  363.  
  364. public:  TCPsHAttrib HAttrib () 
  365. {
  366. return m_hAttrib;
  367. } // end of func
  368. // **********************************************************************
  369.  
  370. public:  TCPsHClass HClass () 
  371. {
  372. return m_hClass;
  373. } // end of func
  374. // **********************************************************************
  375.  
  376. public:  char * Name ()  ;
  377. public:  char * Label ()  ;
  378. public:  char * ColName ()  ;
  379. public:  int Size ()  ;
  380. public:  int RawSize ()  ;
  381. public:  long Type ()  ;
  382. public:  TC_CPsAttribUIData * UIData ()  ;
  383. public:  BOOL IsTransient ()  ;
  384. public:  BOOL IsObject ()  ;
  385. public:  BOOL IsCollection ()  ;
  386. public:  BOOL IsOptional ()  ;
  387. public:  BOOL IsDependent ()  ;
  388. public:  BOOL IsDemandRef ()  ;
  389. public:  TC_CPsClassInfo RelatedTo ()  ;
  390. public:  TC_CPsCollection * GetCollection (TCPsHClass * class_in_cltn = 0)  ;
  391. public:  TC_CPsClassInfo GetClassInCltn ()  ;
  392. public:  TC_CPsAttribInfo GetFK (TCPsClassScope cl_scope)  ;
  393. public:  BOOL SetValue (TC_CPsObject * obj, void * data)  ;
  394. public:  BOOL GetValue (TC_CPsObject * obj, void *data)  ;
  395. public:  TC_CString InfoStr ()  ;
  396. public:  int PrLength ()  ;
  397. public:  void * UserData ()  ;
  398.  
  399. }; // end of class TC_CPsAttribInfo
  400.  
  401. // **********************************************************************
  402.  
  403. // **********************************************************************
  404. class TC_PS_EXPORT TC_CPsClassIter 
  405. {
  406. private:  TCPsHClass m_hClass ;
  407. private:  int * m_Stack ;
  408. private:  int m_sp ;
  409. private:  int m_StackSize ;
  410. public:   TC_CPsClassIter (TCPsHClass cl, int stack_size=20)  ;
  411. public:   ~TC_CPsClassIter ()  ;
  412. public:  BOOL IsLeaf ()  ;
  413. public:  void Set (TCPsHClass cl)  ;
  414. public:  TCPsHClass Next ()  ;
  415. public:  TCPsHClass Prev ()  ;
  416. public:  TCPsHClass Current ()  ;
  417. public:  void BeginReverse ()  ;
  418. public:  TCPsHClass Reverse ()  ;
  419. public:  TCPsHClass operator * ()  ;
  420. public:  TCPsHClass operator ++ (int)  ;
  421. public:  TCPsHClass operator ++ ()  ;
  422. public:  TCPsHClass operator -- (int)  ;
  423. public:  TCPsHClass operator -- ()  ;
  424.  
  425. }; // end of class TC_CPsClassIter
  426.  
  427. // **********************************************************************
  428.  
  429. // **********************************************************************
  430. class TC_PS_EXPORT TC_CPsAttribIter 
  431. {
  432. private:  TCPsHClass m_hClass ;
  433. private:  int m_CurrAttr ;
  434. private:  TCPsHClass m_hCurrClass ;
  435. private:  long m_Filter ;
  436. private:  TC_CPsClassIter m_ci ;
  437. private:  int m_ClassScope ;
  438. public:   TC_CPsAttribIter (TCPsHClass hClass, TCPsClassScope cl_scope = ClassScope_Domain, long filter = 0)  ;
  439. public:  void Reset ()  ;
  440. public:  TC_CPsAttribInfo Next ()  ;
  441. public:  TC_CPsAttribInfo Current ()  ;
  442. public:  TC_CPsAttribInfo operator ++ (int)  ;
  443.  
  444. }; // end of class TC_CPsAttribIter
  445.  
  446. // **********************************************************************
  447.  
  448. #endif // _INC_CPPBIND_HPP
  449.