home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / ibitflag.hp_ / IBITFLAG.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  31.1 KB  |  792 lines

  1. #ifndef _IBITFLAG_
  2.   #define _IBITFLAG_
  3. /*******************************************************************************
  4. * FILE NAME: ibitflag.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the class(es):                                              *
  8. *     IBitFlag - Abstract base class for style and attribute classes.          *
  9. *                                                                              *
  10. *                                                                              *
  11. * COPYRIGHT:                                                                   *
  12. *   Licensed Materials - Property of IBM                                       *
  13. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  14. *   All Rights Reserved                                                        *
  15. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  16. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  17. *                                                                              *
  18. // $Log:   S:/ibmclass/ibaseapp/vcs/ibitflag.hpv  $
  19. // 
  20. //    Rev 1.6   25 Oct 1992 17:30:16   tsuji
  21. // Corrected errant semicolon.
  22. //
  23. //    Rev 1.5   25 Oct 1992 16:56:52   nunn
  24. // changed library name to ICLUI
  25. //
  26. //    Rev 1.4   25 Oct 1992 15:12:52   tsuji
  27. // Format/document in the style of the standard header file.
  28. //
  29. //    Rev 1.3   15 Oct 1992 09:19:14   law
  30. // Removed excess security classification.
  31. //
  32. //    Rev 1.2   13 Oct 1992 19:15:08   tsuji
  33. // Remove no-op virtual destructors, add IBase inheritance, show expanded
  34. // macros in comments.
  35. *******************************************************************************/
  36. #ifndef _IBASE_
  37.   #include <ibase.hpp>
  38. #endif
  39.  
  40. // Forward declarations for other classes:
  41. class IBitFlag;  /* bf */
  42.  
  43. class IBitFlag : public IBase {
  44. /*******************************************************************************
  45. * This is the abstract base class for bitwise styles and attributes used by    *
  46. * window and control classes in the library.  As such, objects of this class   *
  47. * cannot be created.                                                           *
  48. *******************************************************************************/
  49. typedef IBase Inherited;
  50. public:
  51. /*--------------------------------- ACCESSORS ----------------------------------
  52. | This function returns the value of the object.                               |
  53. |   asUnsignedLong - converts object to unsigned long value                    |
  54. ------------------------------------------------------------------------------*/
  55. unsigned long
  56.   asUnsignedLong() const { return ulValue; }
  57.  
  58. protected:
  59. /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
  60. | There is 1 way to construct instances of this class:                         |
  61. |   1. from an unsigned long value                                             |
  62. |      Note that this constructor is protected, since objects derived from     |
  63. |      this class should not be arbitrary constructed.  To provide type safety |
  64. |      for window/control constructors, only existing style/attribute objects  |
  65. |      (and combinations of these objects) can be specified.                   |
  66. ------------------------------------------------------------------------------*/
  67.   IBitFlag ( unsigned long val )
  68.       : ulValue( val ) {;}
  69.  
  70. unsigned long
  71.   ulValue;
  72. }; /* IBitFlag */
  73.  
  74.  
  75. /*----------------------------------  MACROS -----------------------------------
  76. | Below are macros to help generate the definition of classes derived from     |
  77. | IBitFlag and friend functions necessary to combine objects of different      |
  78. | classes.                                                                     |
  79. ------------------------------------------------------------------------------*/
  80. /***************************************************************/
  81. // Macro for the beginning of the definition of a logical base
  82. // bitwise flag class (a class of bitwise flag objects which
  83. // cannot be constructed from a bitwise flag object of another
  84. // class).  This class is not assumed to be nested in another
  85. // class definition.  This macro must be followed by a list of
  86. // instances (separated by commas, terminated with a semicolon)
  87. // and the IBITFLAGCLASSDEF0END macro.
  88. //
  89. // Usage:  IBITFLAGCLASSDEF0START(className)
  90. //           flag1,
  91. //           flag2,
  92. //           flag3;
  93. //         IBITFLAGCLASSDEF0END(className);
  94. //
  95. //           where className is the name of the bitwise flag
  96. //                   class being created
  97. /***************************************************************/
  98. #define IBITFLAGCLASSDEF0START(className)\
  99. class className : public IBitFlag\
  100. {\
  101.   public:\
  102.     static const className
  103.  
  104.  
  105. /***************************************************************/
  106. // Macro for the end of the definition of a logical base
  107. // bitwise flag class (a class of bitwise flag objects which
  108. // cannot be constructed from a bitwise flag object of another
  109. // class).  This class is not assumed to be nested in another
  110. // class definition.  This macro must be preceded by the
  111. // IBITFLAGCLASSDEF0START and a list of instances.
  112. //
  113. // Usage:  IBITFLAGCLASSDEF0START(className)
  114. //           flag1,
  115. //           flag2,
  116. //           flag3;
  117. //         IBITFLAGCLASSDEF0END(className);
  118. //
  119. //           where className is the name of the bitwise flag
  120. //                   class being created
  121. //
  122. // Expands to:
  123. //       class Negated##className : public IBitFlag
  124. //       {
  125. //         friend class className;
  126. //         public:
  127. //           Negated##className  operator & ( Negated##className aFlag ) const
  128. //           {
  129. //             Negated##className aResult(ulValue & aFlag.ulValue);
  130. //             return aResult;
  131. //           }
  132. //         protected:
  133. //           Negated##className ( unsigned long val )
  134. //             : IBitFlag( val ) {;}
  135. //       };
  136. //       className##&  operator |= ( className aFlag )
  137. //       {
  138. //         (*this).ulValue |= aFlag.ulValue;
  139. //         return *this;
  140. //       }
  141. //       Negated##className  operator ~ () const
  142. //       {
  143. //         return Negated##className (~ulValue);
  144. //       }
  145. //       className##&  operator &= ( Negated##className aFlag )
  146. //       {
  147. //         (*this).ulValue &= aFlag.ulValue;
  148. //         return *this;
  149. //       }
  150. //       className  operator | ( className aFlag ) const
  151. //       {
  152. //         className aResult( ulValue | aFlag.ulValue );
  153. //         return aResult;
  154. //       }
  155. //       className  operator & ( Negated##className aFlag ) const
  156. //       {
  157. //         className aResult( ulValue & aFlag.ulValue );
  158. //         return aResult;
  159. //       }
  160. //       unsigned long  operator & ( className aFlag ) const
  161. //       {
  162. //         return (ulValue & aFlag.ulValue);
  163. //       }
  164. //     protected:
  165. //       className ( unsigned long val )
  166. //         : IBitFlag( val ) {;}
  167. //   }
  168. /***************************************************************/
  169. #define IBITFLAGCLASSDEF0END(className)\
  170.     class Negated##className : public IBitFlag\
  171.     {\
  172.       friend class className;\
  173.       public:\
  174.         COMMONNEGBITPUBLIC0( className )\
  175.       protected:\
  176.         COMMONNEGBITPROTECTED( className )\
  177.     };\
  178.     COMMONBITPUBLIC( className )\
  179.     COMMONBITPUBLIC0( className )\
  180.   protected:\
  181.     COMMONBITPROTECTED( className )\
  182. }
  183.  
  184.  
  185. /***************************************************************/
  186. // Macro for the definition of a logical base bitwise flag class
  187. // (a class of bitwise flag objects which cannot be constructed
  188. // from a bitwise flag object of another class), nested within
  189. // another class definition.
  190. //
  191. // Usage:  INESTEDBITFLAGCLASSDEF0(className, assoc);
  192. //           where
  193. //             className is the name of the bitwise flag class
  194. //               being created, and
  195. //             assoc is the name of the window class associated
  196. //               with (and nesting) the bitwise flag class
  197. //         Examples: INESTEDBITFLAGCLASSDEF0(Style, IWindow);
  198. //                   INESTEDBITFLAGCLASSDEF0(Flag, IFrameWindow);
  199. //         This macro is intended to be nested within the
  200. //         associated class definition (e.g. the above examples
  201. //         should be used to create the IWindow::Style and
  202. //         IFrameWindow::Flag classes).
  203. //
  204. // Expands to:
  205. //   class className : public IBitFlag
  206. //   {
  207. //     friend class assoc;
  208. //     public:
  209. //       class Negated##className : public IBitFlag
  210. //       {
  211. //         friend class className;
  212. //         public:
  213. //           Negated##className  operator & ( Negated##className aFlag ) const
  214. //           {
  215. //             Negated##className aResult(ulValue & aFlag.ulValue);
  216. //             return aResult;
  217. //           }
  218. //         protected:
  219. //           Negated##className ( unsigned long val )
  220. //             : IBitFlag( val ) {;}
  221. //       };
  222. //       className##&  operator |= ( className aFlag )
  223. //       {
  224. //         (*this).ulValue |= aFlag.ulValue;
  225. //         return *this;
  226. //       }
  227. //       Negated##className  operator ~ () const
  228. //       {
  229. //         return Negated##className (~ulValue);
  230. //       }
  231. //       className##&  operator &= ( Negated##className aFlag )
  232. //       {
  233. //         (*this).ulValue &= aFlag.ulValue;
  234. //         return *this;
  235. //       }
  236. //       className  operator | ( className aFlag ) const
  237. //       {
  238. //         className aResult( ulValue | aFlag.ulValue );
  239. //         return aResult;
  240. //       }
  241. //       className  operator & ( Negated##className aFlag ) const
  242. //       {
  243. //         className aResult( ulValue & aFlag.ulValue );
  244. //         return aResult;
  245. //       }
  246. //       unsigned long  operator & ( className aFlag ) const
  247. //       {
  248. //         return (ulValue & aFlag.ulValue);
  249. //       }
  250. //     protected:
  251. //       className ( unsigned long val )
  252. //         : IBitFlag( val ) {;}
  253. //   }
  254. /***************************************************************/
  255. #define INESTEDBITFLAGCLASSDEF0(className, assoc)\
  256. class className : public IBitFlag\
  257. {\
  258.   friend class assoc;\
  259.   public:\
  260.     class Negated##className : public IBitFlag\
  261.     {\
  262.       friend class className;\
  263.       public:\
  264.         COMMONNEGBITPUBLIC0( className )\
  265.       protected:\
  266.         COMMONNEGBITPROTECTED( className )\
  267.     };\
  268.     COMMONBITPUBLIC( className )\
  269.     COMMONBITPUBLIC0( className )\
  270.   protected:\
  271.     COMMONBITPROTECTED( className )\
  272. }
  273.  
  274.  
  275. /***************************************************************/
  276. // Macro for the definition of a bitwise flag class whose objects
  277. // can be constructed from an object of another bitwise flag
  278. // class.  Both bitwise flag classes are assumed to be named the
  279. // same, and nested within (different) class definitions.
  280. //
  281. // Usage:  INESTEDBITFLAGCLASSDEF1(className, assoc, base1);
  282. //           where
  283. //             className is the name of the bitwise flag class
  284. //               being created,
  285. //             assoc is the name of the class associated with
  286. //               (and nesting) the bitwise flag class being
  287. //               created, and
  288. //             base1 is the name of the class that nests the
  289. //               bitwise flag class from which the new bitwise
  290. //               flag class can be constructed
  291. //         Examples:
  292. //           INESTEDBITFLAGCLASSDEF1(Style, IControl, IWindow);
  293. //           INESTEDBITFLAGCLASSDEF1(Style, IStaticText, IWindow);
  294. //         This macro is intended to be nested within the
  295. //         associated class definition (e.g. the above examples
  296. //         should be used to create the IControl::Style and
  297. //         IStaticText::Style classes).
  298. //
  299. // Expands to:
  300. //   class className : public IBitFlag
  301. //   {
  302. //     friend class assoc;
  303. //     public:
  304. //       class Negated##className : public IBitFlag
  305. //       {
  306. //         friend class className;
  307. //         public:
  308. //           Negated##className ( base1##::##className##::Negated##className aFlag )
  309. //             : IBitFlag( aFlag.asUnsignedLong() ) {;}
  310. //           friend Negated##className  operator & ( Negated##className lhs,
  311. //                                                   Negated##className rhs );
  312. //         protected:
  313. //           Negated##className ( unsigned long val )
  314. //             : IBitFlag( val ) {;}
  315. //       };
  316. //       className##&  operator |= ( className aFlag )
  317. //       {
  318. //         (*this).ulValue |= aFlag.ulValue;
  319. //         return *this;
  320. //       }
  321. //       Negated##className  operator ~ () const
  322. //       {
  323. //         return Negated##className (~ulValue);
  324. //       }
  325. //       className##&  operator &= ( Negated##className aFlag )
  326. //       {
  327. //         (*this).ulValue &= aFlag.ulValue;
  328. //         return *this;
  329. //       }
  330. //       className ( base1##::##className aFlag )
  331. //         : IBitFlag( aFlag.asUnsignedLong() ) {;}
  332. //       friend className  operator | ( className lhs,
  333. //                                      className rhs );
  334. //       friend className  operator & ( className lhs,
  335. //                                      Negated##className rhs );
  336. //     protected:
  337. //       className ( unsigned long val )
  338. //         : IBitFlag( val ) {;}
  339. //   }
  340. /***************************************************************/
  341. #define INESTEDBITFLAGCLASSDEF1(className, assoc, base1)\
  342. class className : public IBitFlag\
  343. {\
  344.   friend class assoc;\
  345.   public:\
  346.     class Negated##className : public IBitFlag\
  347.     {\
  348.       friend class className;\
  349.       public:\
  350.         COMMONNEGBITPUBLIC1( className, base1 )\
  351.       protected:\
  352.         COMMONNEGBITPROTECTED( className )\
  353.     };\
  354.     COMMONBITPUBLIC( className )\
  355.     COMMONBITPUBLIC1( className, base1 )\
  356.   protected:\
  357.     COMMONBITPROTECTED( className )\
  358. }
  359.  
  360.  
  361. /***************************************************************/
  362. // Macro for the definition of a bitwise flag class whose objects
  363. // can be constructed from an object of two other bitwise flag
  364. // classes.  All the bitwise flag classes are assumed to be named
  365. // the same, and nested within (different) class definitions.
  366. //
  367. // Usage:  INESTEDBITFLAGCLASSDEF2(className, assoc, base1, base2);
  368. //           where
  369. //             className is the name of the bitwise flag class
  370. //               being created,
  371. //             assoc is the name of the class associated with
  372. //               (and nesting) the bitwise flag class being
  373. //               created, and
  374. //             base1 and base2 are the names of the classes that
  375. //               nest the bitwise flag classes from which the new
  376. //               bitwise flag class can be constructed
  377. //         Examples:
  378. //           INESTEDBITFLAGCLASSDEF2(Style, IEntryField, IWindow,
  379. //                                          IControl);
  380. //           INESTEDBITFLAGCLASSDEF2(Style, IButton, IWindow,
  381. //                                          IControl);
  382. //         This macro is intended to be nested within the
  383. //         associated window class definition (e.g. the above
  384. //         examples should be used to create the IEntryField::Style
  385. //         and IButton::Style classes).
  386. //
  387. // Expands to:
  388. //   class className : public IBitFlag
  389. //   {
  390. //     friend class assoc;
  391. //     public:
  392. //       class Negated##className : public IBitFlag
  393. //       {
  394. //         friend class className;
  395. //         public:
  396. //           Negated##className ( base1##::##className##::Negated##className aFlag )
  397. //             : IBitFlag( aFlag.asUnsignedLong() ) {;}
  398. //           friend Negated##className  operator & ( Negated##className lhs,
  399. //                                                   Negated##className rhs );
  400. //           Negated##className ( base2##::##className##::Negated##className aFlag )
  401. //             : IBitFlag( aFlag.asUnsignedLong() ) {;}
  402. //         protected:
  403. //           Negated##className ( unsigned long val )
  404. //             : IBitFlag( val ) {;}
  405. //       };
  406. //       className##&  operator |= ( className aFlag )
  407. //       {
  408. //         (*this).ulValue |= aFlag.ulValue;
  409. //         return *this;
  410. //       }
  411. //       Negated##className  operator ~ () const
  412. //       {
  413. //         return Negated##className (~ulValue);
  414. //       }
  415. //       className##&  operator &= ( Negated##className aFlag )
  416. //       {
  417. //         (*this).ulValue &= aFlag.ulValue;
  418. //         return *this;
  419. //       }
  420. //       className ( base1##::##className aFlag )
  421. //         : IBitFlag( aFlag.asUnsignedLong() ) {;}
  422. //       friend className  operator | ( className lhs,
  423. //                                      className rhs );
  424. //       friend className  operator & ( className lhs,
  425. //                                      Negated##className rhs );
  426. //       className ( base2##::##className aFlag )
  427. //         : IBitFlag( aFlag.asUnsignedLong() ) {;}
  428. //     protected:
  429. //       className ( unsigned long val )
  430. //         : IBitFlag( val ) {;}
  431. //   }
  432. /***************************************************************/
  433. #define INESTEDBITFLAGCLASSDEF2(className, assoc, base1, base2)\
  434. class className : public IBitFlag\
  435. {\
  436.   friend class assoc;\
  437.   public:\
  438.     class Negated##className : public IBitFlag\
  439.     {\
  440.       friend class className;\
  441.       public:\
  442.         COMMONNEGBITPUBLIC1( className, base1 )\
  443.         COMMONNEGBITPUBLICn( className, base2 )\
  444.       protected:\
  445.         COMMONNEGBITPROTECTED( className )\
  446.     };\
  447.     COMMONBITPUBLIC( className )\
  448.     COMMONBITPUBLIC1( className, base1 )\
  449.     COMMONBITPUBLICn( className, base2 )\
  450.   protected:\
  451.     COMMONBITPROTECTED( className )\
  452. }
  453.  
  454.  
  455. /***************************************************************/
  456. // Macro for the definition of a bitwise flag class whose objects
  457. // can be constructed from an object of three other bitwise flag
  458. // classes.  All the bitwise flag classes are assumed to be named
  459. // the same, and nested within (different) class definitions.
  460. //
  461. // Usage:  INESTEDBITFLAGCLASSDEF3(className, assoc, base1, base2,
  462. //                                                          base3)
  463. //           where
  464. //             className is the name of the bitwise flag class
  465. //               being created,
  466. //             assoc is the name of the class associated with
  467. //               (and nesting) the bitwise flag class being
  468. //               created, and
  469. //             base1, base2, and base3 are the names of the
  470. //               classes that nest the bitwise flag classes from
  471. //               which the new bit flag class can be constructed
  472. //         Example:
  473. //           INESTEDBITFLAGCLASSDEF3(Style, IPushButton, IWindow,
  474. //                                          IControl, IButton);
  475. //         This macro is intended to be nested within the
  476. //         associated class definition (e.g. the above example
  477. //         should be used to create the IPushButton::Style class).
  478. //
  479. // Expands to:
  480. //   class className : public IBitFlag
  481. //   {
  482. //     friend class assoc;
  483. //     public:
  484. //       class Negated##className : public IBitFlag
  485. //       {
  486. //         friend class className;
  487. //         public:
  488. //           Negated##className ( base1##::##className##::Negated##className aFlag )
  489. //             : IBitFlag( aFlag.asUnsignedLong() ) {;}
  490. //           friend Negated##className  operator & ( Negated##className lhs,
  491. //                                                   Negated##className rhs );
  492. //           Negated##className ( base2##::##className##::Negated##className aFlag )
  493. //             : IBitFlag( aFlag.asUnsignedLong() ) {;}
  494. //           Negated##className ( base3##::##className##::Negated##className aFlag )
  495. //             : IBitFlag( aFlag.asUnsignedLong() ) {;}
  496. //         protected:
  497. //           Negated##className ( unsigned long val )
  498. //             : IBitFlag( val ) {;}
  499. //       };
  500. //       className##&  operator |= ( className aFlag )
  501. //       {
  502. //         (*this).ulValue |= aFlag.ulValue;
  503. //         return *this;
  504. //       }
  505. //       Negated##className  operator ~ () const
  506. //       {
  507. //         return Negated##className (~ulValue);
  508. //       }
  509. //       className##&  operator &= ( Negated##className aFlag )
  510. //       {
  511. //         (*this).ulValue &= aFlag.ulValue;
  512. //         return *this;
  513. //       }
  514. //       className ( base1##::##className aFlag )
  515. //         : IBitFlag( aFlag.asUnsignedLong() ) {;}
  516. //       friend className  operator | ( className lhs,
  517. //                                      className rhs );
  518. //       friend className  operator & ( className lhs,
  519. //                                      Negated##className rhs );
  520. //       className ( base2##::##className aFlag )
  521. //         : IBitFlag( aFlag.asUnsignedLong() ) {;}
  522. //       className ( base3##::##className aFlag )
  523. //         : IBitFlag( aFlag.asUnsignedLong() ) {;}
  524. //     protected:
  525. //       className ( unsigned long val )
  526. //         : IBitFlag( val ) {;}
  527. //   }
  528. /***************************************************************/
  529. #define INESTEDBITFLAGCLASSDEF3(className, assoc, base1, base2, base3)\
  530. class className : public IBitFlag\
  531. {\
  532.   friend class assoc;\
  533.   public:\
  534.     class Negated##className : public IBitFlag\
  535.     {\
  536.       friend class className;\
  537.       public:\
  538.         COMMONNEGBITPUBLIC1( className, base1 )\
  539.         COMMONNEGBITPUBLICn( className, base2 )\
  540.         COMMONNEGBITPUBLICn( className, base3 )\
  541.       protected:\
  542.         COMMONNEGBITPROTECTED( className )\
  543.     };\
  544.     COMMONBITPUBLIC( className )\
  545.     COMMONBITPUBLIC1( className, base1 )\
  546.     COMMONBITPUBLICn( className, base2 )\
  547.     COMMONBITPUBLICn( className, base3 )\
  548.   protected:\
  549.     COMMONBITPROTECTED( className )\
  550. }
  551.  
  552.  
  553. /***************************************************************/
  554. // Macro for the definition of a bitwise flag class whose objects
  555. // can be constructed from an object of four other bitwise flag
  556. // classes.  All the bitwise flag classes are assumed to be named
  557. // the same, and nested within (different) class definitions.
  558. //
  559. // Usage:  INESTEDBITFLAGCLASSDEF4(className, assoc, base1, base2,
  560. //                                                   base3, base4);
  561. //           where
  562. //             className is the name of the bitwise flag class
  563. //               being created,
  564. //             assoc is the name of the class associated with
  565. //               (and nesting) the bitwise flag class being
  566. //               created, and
  567. //             base1, base2, base3, and base4 are the names of the
  568. //               classes that nest the bitwise flag classes from
  569. //               which the new bit flag class can be constructed
  570. //         This macro is intended to be nested within the
  571. //         associated class definition.
  572. //
  573. // Expands to:
  574. //   class className : public IBitFlag
  575. //   {
  576. //     friend class assoc;
  577. //     public:
  578. //       class Negated##className : public IBitFlag
  579. //       {
  580. //         friend class className;
  581. //         public:
  582. //           Negated##className ( base1##::##className##::Negated##className aFlag )
  583. //             : IBitFlag( aFlag.asUnsignedLong() ) {;}
  584. //           friend Negated##className  operator & ( Negated##className lhs,
  585. //                                                   Negated##className rhs );
  586. //           Negated##className ( base2##::##className##::Negated##className aFlag )
  587. //             : IBitFlag( aFlag.asUnsignedLong() ) {;}
  588. //           Negated##className ( base3##::##className##::Negated##className aFlag )
  589. //             : IBitFlag( aFlag.asUnsignedLong() ) {;}
  590. //           Negated##className ( base4##::##className##::Negated##className aFlag )
  591. //             : IBitFlag( aFlag.asUnsignedLong() ) {;}
  592. //         protected:
  593. //           Negated##className ( unsigned long val )
  594. //             : IBitFlag( val ) {;}
  595. //       };
  596. //       className##&  operator |= ( className aFlag )
  597. //       {
  598. //         (*this).ulValue |= aFlag.ulValue;
  599. //         return *this;
  600. //       }
  601. //       Negated##className  operator ~ () const
  602. //       {
  603. //         return Negated##className (~ulValue);
  604. //       }
  605. //       className##&  operator &= ( Negated##className aFlag )
  606. //       {
  607. //         (*this).ulValue &= aFlag.ulValue;
  608. //         return *this;
  609. //       }
  610. //       className ( base1##::##className aFlag )
  611. //         : IBitFlag( aFlag.asUnsignedLong() ) {;}
  612. //       friend className  operator | ( className lhs,
  613. //                                      className rhs );
  614. //       friend className  operator & ( className lhs,
  615. //                                      Negated##className rhs );
  616. //       className ( base2##::##className aFlag )
  617. //         : IBitFlag( aFlag.asUnsignedLong() ) {;}
  618. //       className ( base3##::##className aFlag )
  619. //         : IBitFlag( aFlag.asUnsignedLong() ) {;}
  620. //       className ( base4##::##className aFlag )
  621. //         : IBitFlag( aFlag.asUnsignedLong() ) {;}
  622. //     protected:
  623. //       className ( unsigned long val )
  624. //         : IBitFlag( val ) {;}
  625. //   }
  626. /***************************************************************/
  627. #define INESTEDBITFLAGCLASSDEF4(className, assoc, base1, base2, base3, base4)\
  628. class className : public IBitFlag\
  629. {\
  630.   friend class assoc;\
  631.   public:\
  632.     class Negated##className : public IBitFlag\
  633.     {\
  634.       friend class className;\
  635.       public:\
  636.         COMMONNEGBITPUBLIC1( className, base1 )\
  637.         COMMONNEGBITPUBLICn( className, base2 )\
  638.         COMMONNEGBITPUBLICn( className, base3 )\
  639.         COMMONNEGBITPUBLICn( className, base4 )\
  640.       protected:\
  641.         COMMONNEGBITPROTECTED( className )\
  642.     };\
  643.     COMMONBITPUBLIC( className )\
  644.     COMMONBITPUBLIC1( className, base1 )\
  645.     COMMONBITPUBLICn( className, base2 )\
  646.     COMMONBITPUBLICn( className, base3 )\
  647.     COMMONBITPUBLICn( className, base4 )\
  648.   protected:\
  649.     COMMONBITPROTECTED( className )\
  650. }
  651.  
  652.  
  653. /***************************************************************/
  654. // Macro for the definition of global functions that operate on
  655. // a class of bitwise flag objects nested within a class
  656. // definition.  (These are global, rather than member functions,
  657. // to allow for communitative operations between objects of
  658. // different bitwise flag classes.)
  659. // Note: This macro should not be used to create global
  660. //       functions for a logical base style class (one created
  661. //       with the INESTEDBITFLAGCLASSDEF0 macro).
  662. //
  663. // Usage:  INESTEDBITFLAGCLASSFUNCS(className, assoc);
  664. //           where
  665. //             className is the name of a bitwise flag class, and
  666. //             assoc is the name of the class associated with
  667. //               with (and nesting) the bitwise flag class
  668. //         Examples: INESTEDBITFLAGCLASSFUNCS(Style, IControl);
  669. //                   INESTEDBITFLAGCLASSFUNCS(Style, IEntryField);
  670. //         This macro should be used outside of all class
  671. //         definitions.
  672. //
  673. // Expands to:
  674. //   inline assoc##::##className  operator | ( assoc##::##className lhs,
  675. //                                             assoc##::##className rhs )
  676. //   {
  677. //     assoc##::##className aResult(lhs.ulValue | rhs.ulValue);
  678. //     return aResult;
  679. //   }
  680. //   inline assoc##::##className
  681. //     operator & ( assoc##::##className lhs,
  682. //                  assoc##::##className##::Negated##className rhs )
  683. //   {
  684. //     assoc##::##className aResult( lhs.ulValue & rhs.asUnsignedLong() );
  685. //     return aResult;
  686. //   }
  687. //   inline assoc##::##className##::Negated##className
  688. //     operator & ( assoc##::##className##::Negated##className lhs,
  689. //                  assoc##::##className##::Negated##className rhs )
  690. //   {
  691. //     assoc##::##className##::Negated##className aResult(lhs.ulValue & rhs.ulValue);
  692. //     return aResult;
  693. //   }
  694. //   inline unsigned long  operator & ( assoc##::##className lhs,
  695. //                                      assoc##::##className rhs )
  696. //   {
  697. //     return ( lhs.asUnsignedLong() & rhs.asUnsignedLong() );
  698. //   }
  699. /***************************************************************/
  700. #define INESTEDBITFLAGCLASSFUNCS(className, assoc)\
  701. inline assoc##::##className  operator | ( assoc##::##className lhs,\
  702.                                           assoc##::##className rhs )\
  703. {\
  704.   assoc##::##className aResult(lhs.ulValue | rhs.ulValue);\
  705.   return aResult;\
  706. }\
  707. inline assoc##::##className\
  708.   operator & ( assoc##::##className lhs,\
  709.                assoc##::##className##::Negated##className rhs )\
  710. {\
  711.   assoc##::##className aResult( lhs.ulValue & rhs.asUnsignedLong() );\
  712.   return aResult;\
  713. }\
  714. inline assoc##::##className##::Negated##className\
  715.   operator & ( assoc##::##className##::Negated##className lhs,\
  716.                assoc##::##className##::Negated##className rhs )\
  717. {\
  718.   assoc##::##className##::Negated##className aResult(lhs.ulValue & rhs.ulValue);\
  719.   return aResult;\
  720. }\
  721. inline unsigned long  operator & ( assoc##::##className lhs,\
  722.                                    assoc##::##className rhs )\
  723. {\
  724.   return ( lhs.asUnsignedLong() & rhs.asUnsignedLong() );\
  725. }
  726.  
  727.  
  728. /***************************************************************/
  729. // Helper macros.
  730. // These are not intended to be used outside of this file.
  731. /***************************************************************/
  732. #define COMMONBITPUBLIC(className)\
  733.     className##&  operator |= ( className aFlag )\
  734.     {\
  735.       this->ulValue |= aFlag.ulValue;\
  736.       return *this;\
  737.     }\
  738.     Negated##className  operator ~ () const\
  739.     {\
  740.       return Negated##className (~ulValue);\
  741.     }\
  742.     className##&  operator &= ( Negated##className aFlag )\
  743.     {\
  744.       this->ulValue &= aFlag.ulValue;\
  745.       return *this;\
  746.     }
  747. #define COMMONBITPUBLIC0(className)\
  748.     className  operator | ( className aFlag ) const\
  749.     {\
  750.       className aResult( ulValue | aFlag.ulValue );\
  751.       return aResult;\
  752.     }\
  753.     className  operator & ( Negated##className aFlag ) const\
  754.     {\
  755.       className aResult( ulValue & aFlag.ulValue );\
  756.       return aResult;\
  757.     }\
  758.     unsigned long  operator & ( className aFlag ) const\
  759.     {\
  760.       return (ulValue & aFlag.ulValue);\
  761.     }
  762. #define COMMONBITPUBLIC1(className, baseName)\
  763.     COMMONBITPUBLICn(className, baseName)\
  764.     friend className  operator | ( className lhs,\
  765.                                    className rhs );\
  766.     friend className  operator & ( className lhs,\
  767.                                    Negated##className rhs );
  768. #define COMMONBITPUBLICn(className, baseName)\
  769.     className ( baseName##::##className aFlag )\
  770.       : IBitFlag( aFlag.asUnsignedLong() ) {;}
  771. #define COMMONNEGBITPUBLIC0(className)\
  772.         Negated##className  operator & ( Negated##className aFlag ) const\
  773.         {\
  774.           Negated##className aResult(ulValue & aFlag.ulValue);\
  775.           return aResult;\
  776.         }
  777. #define COMMONNEGBITPUBLIC1(className, baseName)\
  778.         COMMONNEGBITPUBLICn(className, baseName)\
  779.         friend Negated##className  operator & ( Negated##className lhs,\
  780.                                                 Negated##className rhs );
  781. #define COMMONNEGBITPUBLICn(className, baseName)\
  782.         Negated##className ( baseName##::##className##::Negated##className aFlag )\
  783.           : IBitFlag( aFlag.asUnsignedLong() ) {;}
  784. #define COMMONBITPROTECTED(className)\
  785.         className ( unsigned long val )\
  786.           : IBitFlag( val ) {;}
  787. #define COMMONNEGBITPROTECTED(className)\
  788.         Negated##className ( unsigned long val )\
  789.           : IBitFlag( val ) {;}
  790.  
  791. #endif /* IBITFLAG */
  792.