home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / visbuild / vbsample / ivbdbl.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-16  |  40.1 KB  |  887 lines

  1. /*******************************************************************************
  2. * FILE NAME: ivbdbl.cpp                                                        *
  3. *                                                                              *
  4. * DESCRIPTION:                                                                 *
  5. *   Class implementation of the class(es):                                     *
  6. *    IVBDoublePart - IBM VB sample Double part.                                *
  7. *                                                                              *
  8. * COPYRIGHT:                                                                   *
  9. *   IBM(R) VisualAge(TM) for C++                                               *
  10. *   (C) Copyright International Business Machines Corporation 1991, 1996       *
  11. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  12. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  13. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  14. *                                                                              *
  15. *   This program will not run in DOS mode.                                     *
  16. *                                                                              *
  17. * DISCLAIMER OF WARRANTIES:                                                    *
  18. *   The following [enclosed] code is sample code created by IBM                *
  19. *   Corporation.  This sample code is not part of any standard IBM product     *
  20. *   and is provided to you solely for the purpose of assisting you in the      *
  21. *   development of your applications.  The code is provided "AS IS",           *
  22. *   without warranty of any kind.  IBM shall not be liable for any damages     *
  23. *   arising out of your use of the sample code, even if they have been         *
  24. *   advised of the possibility of such damages.                                *
  25. *******************************************************************************/
  26.  
  27. #ifndef _IVBDBL_
  28.   #include <ivbdbl.hpp>
  29. #endif
  30.  
  31. #ifndef _INOTIFEV_
  32.   #include <inotifev.hpp>
  33. #endif
  34.  
  35.   #include <complex.h>
  36.  
  37.   #include <math.h>
  38.  
  39.  
  40.  
  41. /*------------------------------------------------------------------------------
  42. | IVBDoublePart::IVBDoublePart                                                 |
  43. |                                                                              |
  44. | Standard constructor.                                                        |
  45. ------------------------------------------------------------------------------*/
  46. #pragma export (IVBDoublePart::IVBDoublePart(double aValue),, 2700)
  47. IVBDoublePart::IVBDoublePart(double aValue) : IVBDataTypePart ()
  48.     ,iValue (aValue)
  49.     ,iDefaultValue (0)
  50.     ,iLowLimit (DBL_MIN)
  51.     ,iHighLimit (DBL_MAX)
  52. {
  53.   enableNotification ();
  54. }
  55.  
  56. /*------------------------------------------------------------------------------
  57. | IVBDoublePart::IVBDoublePart                                                 |
  58. |                                                                              |
  59. | Standard copy constructor.                                                   |
  60. ------------------------------------------------------------------------------*/
  61. #pragma export (IVBDoublePart::IVBDoublePart(const IVBDoublePart&),, 2701)
  62. IVBDoublePart::IVBDoublePart (const IVBDoublePart& partCopy)
  63.   : IVBDataTypePart (partCopy)
  64.     ,iValue (partCopy.value ())
  65.     ,iDefaultValue (partCopy.defaultValue ())
  66.     ,iLowLimit (partCopy.lowLimit ())
  67.     ,iHighLimit (partCopy.highLimit ())
  68. {
  69.   enableNotification ();
  70. }
  71.  
  72. /*------------------------------------------------------------------------------
  73. | IVBDoublePart::IVBDoublePart                                                 |
  74. |                                                                              |
  75. | Standard operator=                                                           |
  76. ------------------------------------------------------------------------------*/
  77. #pragma export (IVBDoublePart::operator= (const IVBDoublePart&),, 2702)
  78. IVBDoublePart& IVBDoublePart::operator= (const IVBDoublePart& aIVBDoublePart)
  79. {
  80.   if (this == &aIVBDoublePart) {
  81.     return *this;
  82.   } /* endif */
  83.   Inherited::operator=(aIVBDoublePart);
  84.   setValue(aIVBDoublePart.value());
  85.   setDefaultValue(aIVBDoublePart.defaultValue());
  86.   setLowLimit(aIVBDoublePart.lowLimit());
  87.   setHighLimit(aIVBDoublePart.highLimit());
  88.   return *this;
  89. }
  90.  
  91. /*------------------------------------------------------------------------------
  92. | IVBDoublePart::~IVBDoublePart                                                |
  93. |                                                                              |
  94. | IVBDoublePart destructor.                                                    |
  95. ------------------------------------------------------------------------------*/
  96. #pragma export (IVBDoublePart::~IVBDoublePart(),, 2703)
  97. IVBDoublePart::~IVBDoublePart()
  98. {
  99. }
  100.  
  101. /*------------------------------------------------------------------------------
  102. | IVBDoublePart::asString                                                      |
  103. |                                                                              |
  104. | Perform asString.                                                            |
  105. ------------------------------------------------------------------------------*/
  106. #pragma export (IVBDoublePart::asString() const,, 2704)
  107. IString IVBDoublePart::asString () const
  108. {
  109.   return valueAsText();
  110. }
  111.  
  112. /*------------------------------------------------------------------------------
  113. | IVBDoublePart::value                                                         |
  114. |                                                                              |
  115. | Return the value attribute.                                                  |
  116. ------------------------------------------------------------------------------*/
  117. #pragma export (IVBDoublePart::value() const,, 2705)
  118. double IVBDoublePart::value () const
  119. {
  120.   return iValue;
  121. }
  122.  
  123. /*------------------------------------------------------------------------------
  124. | IVBDoublePart::setValue                                                      |
  125. |                                                                              |
  126. | Set the value attribute.                                                     |
  127. ------------------------------------------------------------------------------*/
  128. #pragma export (IVBDoublePart::setValue(const double),, 2706)
  129. IVBDoublePart& IVBDoublePart::setValue (double aValue)
  130. {
  131.   if (iValue != aValue) {
  132.     double oldValue = iValue;
  133.     iValue = aValue;
  134.     notifyObservers(INotificationEvent(valueId, *this,
  135.                       true, (void*)&iValue));
  136.     if (iValue < 0) {
  137.       if (!(oldValue < 0)) {
  138.         notifyObservers(INotificationEvent(valueNegativeId, *this,
  139.                         true, (void*)&iValue));
  140.       } ; /* endif */
  141.     } ;
  142.     if (iValue > 0) {
  143.       if (!(oldValue > 0)) {
  144.         notifyObservers(INotificationEvent(valuePositiveId, *this,
  145.                         true, (void*)&iValue));
  146.       } ; /* endif */
  147.     } ; /* endif */
  148.     if (iValue == 0) {
  149.       notifyObservers(INotificationEvent(valueZeroId, *this,
  150.                       true, (void*)&iValue));
  151.     }
  152.     else {
  153.       if (oldValue == 0) {
  154.         notifyObservers(INotificationEvent(valueNotZeroId, *this,
  155.                         true, (void*)&iValue));
  156.       } ; /* endif */
  157.     } ; /* endif */
  158.     if (iDefaultValue == iValue) {
  159.       notifyObservers(INotificationEvent(valueEqualDefaultId, *this,
  160.                       true, (void*)&iValue));
  161.     }
  162.     else {
  163.       if (iDefaultValue == oldValue) {
  164.         notifyObservers(INotificationEvent(valueNotEqualDefaultId, *this,
  165.                         true, (void*)&iValue));
  166.       } /* endif */
  167.     } /* endif */
  168.     if (iValue == iLowLimit) {
  169.       notifyObservers(INotificationEvent(valueEqualLowLimitId, *this,
  170.                       true, (void*)&iValue));
  171.     } ; /* endif */
  172.     if (iLowLimit != DBL_MIN) {
  173.       if (iValue < iLowLimit) {
  174.         if (!(oldValue < iLowLimit)) {
  175.           notifyObservers(INotificationEvent(valueBelowLowLimitId, *this,
  176.                           true, (void*)&iValue));
  177.         } ; /* endif */
  178.       } ; /* endif */
  179.     } ; /* endif */
  180.     if (iValue == iHighLimit) {
  181.       notifyObservers(INotificationEvent(valueEqualHighLimitId, *this,
  182.                       true, (void*)&iValue));
  183.     } ; /* endif */
  184.     if (iHighLimit != DBL_MAX) {
  185.       if (iValue > iHighLimit) {
  186.         if (!(oldValue > iHighLimit)) {
  187.           notifyObservers(INotificationEvent(valueAboveHighLimitId, *this,
  188.                           true, (void*)&iValue));
  189.         } ; /* endif */
  190.       } ; /* endif */
  191.     } ; /* endif */
  192.     if ((iValue >= iLowLimit) && (iValue <= iHighLimit)) {
  193.       if (!((oldValue >= iLowLimit) && (oldValue <= iHighLimit))) {
  194.         notifyObservers(INotificationEvent(valueWithinLimitsId, *this,
  195.                         true, (void*)&iValue));
  196.       } ; /* endif */
  197.     }
  198.     else {
  199.       if (((oldValue >= iLowLimit) && (oldValue <= iHighLimit))) {
  200.         notifyObservers(INotificationEvent(valueOutsideLimitsId, *this,
  201.                         true, (void*)&iValue));
  202.       } ; /* endif */
  203.     } ; /* endif */
  204.   } ; /* endif */
  205.   return *this;
  206. }
  207.  
  208. /*------------------------------------------------------------------------------
  209. | IVBDoublePart::setValue                                                      |
  210. |                                                                              |
  211. | Set the value attribute.                                                     |
  212. ------------------------------------------------------------------------------*/
  213. #pragma export (IVBDoublePart::setValue(),, 2707)
  214. IVBDoublePart& IVBDoublePart::setValue ()
  215. {
  216.   return setValue(defaultValue());
  217. }
  218.  
  219. /*------------------------------------------------------------------------------
  220. | IVBDoublePart::valueAsText                                                   |
  221. |                                                                              |
  222. | Return the valueAsText attribute.                                            |
  223. ------------------------------------------------------------------------------*/
  224. #pragma export (IVBDoublePart::valueAsText() const,, 2708)
  225. IString IVBDoublePart::valueAsText () const
  226. {
  227.   return IString (value());
  228. }
  229.  
  230. /*------------------------------------------------------------------------------
  231. | IVBDoublePart::setValueAsText                                                |
  232. |                                                                              |
  233. | Set the valueAsText attribute.                                               |
  234. ------------------------------------------------------------------------------*/
  235. #pragma export (IVBDoublePart::setValueAsText(const IString&),, 2709)
  236. IVBDoublePart& IVBDoublePart::setValueAsText (const IString& aValueAsText)
  237. {
  238. #ifdef IC_PM
  239.   IString tempValueString(aValueAsText);
  240.   setValue (aValueAsText.asDouble());
  241.   tempValueString = tempValueString.strip();
  242.   Boolean   inValidDbl=0;
  243.   int iExponent;
  244.  
  245.  
  246.   IString firstCharOfString(tempValueString.subString(1,1));   //Gets 1st char of string
  247.   Boolean testFirstChar=firstCharOfString.indexOfAnyOf("+-");  //Checks 2C if 1st char is + or -
  248.  
  249.   if (testFirstChar)
  250.     tempValueString=tempValueString.subString(2);              //Uses rest of string after sign
  251.  
  252.   tempValueString = tempValueString.strip();
  253.  
  254.   int numDecimalPoints =tempValueString.occurrencesOf(".");
  255.  
  256.   if (numDecimalPoints>1)
  257.     inValidDbl=1;
  258.   else {
  259.     int numExponents =(tempValueString.occurrencesOf("E")+tempValueString.occurrencesOf("e"));
  260.     iExponent =tempValueString.indexOfAnyOf("Ee");
  261.     if (numExponents>1)
  262.       inValidDbl=1;
  263.     else if (numExponents==1){
  264.  
  265.    /*  *****Verifies real part of Double ********  */
  266.       IString realPartStr=tempValueString.subString(1,iExponent-1);
  267.       Boolean isItNotReal=realPartStr.indexOfAnyBut(".0123456789");
  268.       if (isItNotReal)
  269.         inValidDbl=1;
  270.  
  271.    /*  *****Verifies exponential part of Double ********  */
  272.       IString exponStr=tempValueString.subString(iExponent);
  273.       Boolean exponStrNotGood=exponStr.indexOfAnyBut("Ee+-0123456789");
  274.       if (exponStrNotGood)
  275.         inValidDbl=1;
  276.     }  /*else if*/
  277.  
  278.       else {/* if numExponents ==0 */
  279.       Boolean isItNotReal=tempValueString.indexOfAnyBut(".0123456789");
  280.       if (isItNotReal)
  281.         inValidDbl=1;
  282.  
  283.     } /*else*/
  284.   }/*else  */
  285.  
  286.   IString eventData(aValueAsText);
  287.   if (inValidDbl) {
  288.     notifyObservers(INotificationEvent(inputStringNotValidId, *this,
  289.                       true, (void*)&eventData));
  290.   } else {
  291.     notifyObservers(INotificationEvent(inputStringIsValidId, *this,
  292.                       true, (void*)&eventData));
  293.   } /* endif */
  294. #endif
  295. #ifdef IC_WIN
  296.   setValue (aValueAsText.asDouble());
  297.   Boolean iValid = aValueAsText.indexOfAnyBut("+-0123456789. ");
  298.   if (iValid) {
  299.     IString eventData(aValueAsText);
  300.     notifyObservers(INotificationEvent(inputStringNotValidId, *this,
  301.                       true, (void*)&eventData));
  302.   } else {
  303.     IString eventData(aValueAsText);
  304.     notifyObservers(INotificationEvent(inputStringIsValidId, *this,
  305.                       true, (void*)&eventData));
  306.   } /* endif */
  307. #endif
  308.   return *this;
  309. }
  310.  
  311. /*------------------------------------------------------------------------------
  312. | IVBDoublePart::setValueAsText                                                |
  313. |                                                                              |
  314. | Set the valueAsText attribute.                                               |
  315. ------------------------------------------------------------------------------*/
  316. #pragma export (IVBDoublePart::setValueAsText(const IString*),, 2710)
  317. IVBDoublePart& IVBDoublePart::setValueAsText (const IString* aValueAsText)
  318. {
  319.   return setValueAsText (*aValueAsText);
  320. }
  321.  
  322. /*------------------------------------------------------------------------------
  323. | IVBDoublePart::valueAs1Based                                                 |
  324. |                                                                              |
  325. | Return the valueAs1Based attribute.                                          |
  326. ------------------------------------------------------------------------------*/
  327. #pragma export (IVBDoublePart::valueAs1Based() const,, 2711)
  328. double IVBDoublePart::valueAs1Based () const
  329. {
  330.   return (value() + 1) ;
  331. }
  332.  
  333. /*------------------------------------------------------------------------------
  334. | IVBDoublePart::setValueAs1Based                                              |
  335. |                                                                              |
  336. | Set the valueAs1Based attribute.                                             |
  337. ------------------------------------------------------------------------------*/
  338. #pragma export (IVBDoublePart::setValueAs1Based(double),, 2712)
  339. IVBDoublePart& IVBDoublePart::setValueAs1Based (double aValueAs1Based)
  340. {
  341.   return setValue (aValueAs1Based - 1);
  342. }
  343.  
  344. /*------------------------------------------------------------------------------
  345. | IVBDoublePart::defaultValue                                                  |
  346. |                                                                              |
  347. | Return the defaultValue attribute.                                           |
  348. ------------------------------------------------------------------------------*/
  349. #pragma export (IVBDoublePart::defaultValue() const,, 2713)
  350. double IVBDoublePart::defaultValue () const
  351. {
  352.   return iDefaultValue;
  353. }
  354.  
  355. /*------------------------------------------------------------------------------
  356. | IVBDoublePart::setDefaultValue                                               |
  357. |                                                                              |
  358. | Set the defaultValue attribute.                                              |
  359. ------------------------------------------------------------------------------*/
  360. #pragma export (IVBDoublePart::setDefaultValue(const double),, 2714)
  361. IVBDoublePart& IVBDoublePart::setDefaultValue (double aDefaultValue)
  362. {
  363.   if (iDefaultValue != aDefaultValue) {
  364.     double oldValue = iDefaultValue;
  365.     iDefaultValue = aDefaultValue;
  366.     notifyObservers(INotificationEvent(defaultValueId, *this,
  367.                       true, (void*)&iDefaultValue));
  368.     if (iDefaultValue == iValue) {
  369.       notifyObservers(INotificationEvent(valueEqualDefaultId, *this,
  370.                       true, (void*)&iValue));
  371.     }
  372.     else {
  373.       if (oldValue == iValue) {
  374.         notifyObservers(INotificationEvent(valueNotEqualDefaultId, *this,
  375.                         true, (void*)&iValue));
  376.       } /* endif */
  377.     } /* endif */
  378.   } /* endif */
  379.   return *this;
  380. }
  381.  
  382. /*------------------------------------------------------------------------------
  383. | IVBDoublePart::isValueEqualDefault                                           |
  384. |                                                                              |
  385. | Return the valueEqualDefault attribute.                                      |
  386. ------------------------------------------------------------------------------*/
  387. #pragma export (IVBDoublePart::isValueEqualDefault() const,, 2715)
  388. Boolean IVBDoublePart::isValueEqualDefault () const
  389. {
  390.   return (value() == defaultValue ()) ;
  391. }
  392.  
  393. /*------------------------------------------------------------------------------
  394. | IVBDoublePart::isValueNotEqualDefault                                        |
  395. |                                                                              |
  396. | Return the valueNotEqualDefault attribute.                                   |
  397. ------------------------------------------------------------------------------*/
  398. #pragma export (IVBDoublePart::isValueNotEqualDefault() const,, 2716)
  399. Boolean IVBDoublePart::isValueNotEqualDefault () const
  400. {
  401.   return (value() != defaultValue ()) ;
  402. }
  403.  
  404. /*------------------------------------------------------------------------------
  405. | IVBDoublePart::lowLimit                                                      |
  406. |                                                                              |
  407. | Return the lowLimit attribute.                                               |
  408. ------------------------------------------------------------------------------*/
  409. #pragma export (IVBDoublePart::lowLimit() const,, 2717)
  410. double IVBDoublePart::lowLimit () const
  411. {
  412.   return iLowLimit;
  413. }
  414.  
  415. /*------------------------------------------------------------------------------
  416. | IVBDoublePart::setLowLimit                                                   |
  417. |                                                                              |
  418. | Set the lowLimit attribute.                                                  |
  419. ------------------------------------------------------------------------------*/
  420. #pragma export (IVBDoublePart::setLowLimit(const double),, 2718)
  421. IVBDoublePart& IVBDoublePart::setLowLimit (double aLowLimit)
  422. {
  423.   if (iLowLimit != aLowLimit) {
  424.     double oldValue = iLowLimit;
  425.     iLowLimit = aLowLimit;
  426.     notifyObservers(INotificationEvent(lowLimitId, *this,
  427.                       true, (void*)&iLowLimit));
  428.     if (iValue == lowLimit()) {
  429.       notifyObservers(INotificationEvent(valueEqualLowLimitId, *this,
  430.                       true, (void*)&iValue));
  431.     } ; /* endif */
  432.     if (lowLimit() != DBL_MIN) {
  433.       if (iValue < iLowLimit) {
  434.         if (!(iValue < oldValue)) {
  435.           notifyObservers(INotificationEvent(valueBelowLowLimitId, *this,
  436.                           true, (void*)&iValue));
  437.         } ; /* endif */
  438.       } ; /* endif */
  439.     } ; /* endif */
  440.     if ((iValue >= lowLimit()) && (iValue <= highLimit())) {
  441.       if (!((iValue >= oldValue) && (iValue <= highLimit()))) {
  442.         notifyObservers(INotificationEvent(valueWithinLimitsId, *this,
  443.                         true, (void*)&iLowLimit));
  444.       } ; /* endif */
  445.     }
  446.     else {
  447.       if ((iValue >= oldValue) && (iValue <= highLimit())) {
  448.         notifyObservers(INotificationEvent(valueOutsideLimitsId, *this,
  449.                         true, (void*)&iLowLimit));
  450.       } ; /* endif */
  451.     } ; /* endif */
  452.   } /* endif */
  453.   return *this;
  454. }
  455.  
  456. /*------------------------------------------------------------------------------
  457. | IVBDoublePart::highLimit                                                     |
  458. |                                                                              |
  459. | Return the highLimit attribute.                                              |
  460. ------------------------------------------------------------------------------*/
  461. #pragma export (IVBDoublePart::highLimit() const,, 2719)
  462. double IVBDoublePart::highLimit () const
  463. {
  464.   return iHighLimit;
  465. }
  466.  
  467. /*------------------------------------------------------------------------------
  468. | IVBDoublePart::setHighLimit                                                  |
  469. |                                                                              |
  470. | Set the highLimit attribute.                                                 |
  471. ------------------------------------------------------------------------------*/
  472. #pragma export (IVBDoublePart::setHighLimit(const double),, 2720)
  473. IVBDoublePart& IVBDoublePart::setHighLimit (double aHighLimit)
  474. {
  475.   if (iHighLimit != aHighLimit) {
  476.     double oldValue = iHighLimit;
  477.     iHighLimit = aHighLimit;
  478.     notifyObservers(INotificationEvent(highLimitId, *this,
  479.                       true, (void*)&iHighLimit));
  480.     if (iValue == highLimit()) {
  481.       notifyObservers(INotificationEvent(valueEqualHighLimitId, *this,
  482.                       true, (void*)&iValue));
  483.     } ; /* endif */
  484.     if (highLimit() != DBL_MAX) {
  485.       if (iValue > iHighLimit) {
  486.         if (!(iValue > oldValue)) {
  487.           notifyObservers(INotificationEvent(valueAboveHighLimitId, *this,
  488.                           true, (void*)&iValue));
  489.         } ; /* endif */
  490.       } ; /* endif */
  491.     } ; /* endif */
  492.     if ((iValue >= lowLimit()) && (iValue <= highLimit())) {
  493.       if (!((iValue >= lowLimit()) && (iValue <= oldValue))) {
  494.         notifyObservers(INotificationEvent(valueWithinLimitsId, *this,
  495.                         true, (void*)&iHighLimit));
  496.       } ; /* endif */
  497.     }
  498.     else {
  499.       if ((iValue >= lowLimit()) && (iValue <= oldValue)) {
  500.         notifyObservers(INotificationEvent(valueOutsideLimitsId, *this,
  501.                         true, (void*)&iHighLimit));
  502.       } ; /* endif */
  503.     } ; /* endif */
  504.   } /* endif */
  505.   return *this;
  506. }
  507.  
  508. /*------------------------------------------------------------------------------
  509. | IVBDoublePart::isValueEqualLowLimit                                          |
  510. |                                                                              |
  511. | Return the valueEqualLowLimit attribute.                                     |
  512. ------------------------------------------------------------------------------*/
  513. #pragma export (IVBDoublePart::isValueEqualLowLimit() const,, 2721)
  514. Boolean IVBDoublePart::isValueEqualLowLimit () const
  515. {
  516.   return (value() == lowLimit ()) ;
  517. }
  518.  
  519. /*------------------------------------------------------------------------------
  520. | IVBDoublePart::isValueEqualHighLimit                                         |
  521. |                                                                              |
  522. | Return the valueEqualHighLimit attribute.                                    |
  523. ------------------------------------------------------------------------------*/
  524. #pragma export (IVBDoublePart::isValueEqualHighLimit() const,, 2722)
  525. Boolean IVBDoublePart::isValueEqualHighLimit () const
  526. {
  527.   return (value() == highLimit ()) ;
  528. }
  529.  
  530. /*------------------------------------------------------------------------------
  531. | IVBDoublePart::isValueBelowLowLimit                                          |
  532. |                                                                              |
  533. | Return the valueBelowLowLimit attribute.                                     |
  534. ------------------------------------------------------------------------------*/
  535. #pragma export (IVBDoublePart::isValueBelowLowLimit() const,, 2723)
  536. Boolean IVBDoublePart::isValueBelowLowLimit () const
  537. {
  538.   return (value() < lowLimit ()) ;
  539. }
  540.  
  541. /*------------------------------------------------------------------------------
  542. | IVBDoublePart::isValueAboveHighLimit                                         |
  543. |                                                                              |
  544. | Return the valueAboveHighLimit attribute.                                    |
  545. ------------------------------------------------------------------------------*/
  546. #pragma export (IVBDoublePart::isValueAboveHighLimit() const,, 2724)
  547. Boolean IVBDoublePart::isValueAboveHighLimit () const
  548. {
  549.   return (value() > highLimit ()) ;
  550. }
  551.  
  552. /*------------------------------------------------------------------------------
  553. | IVBDoublePart::isValueOutsideLimits                                          |
  554. |                                                                              |
  555. | Return the valueOutsideLimits attribute.                                     |
  556. ------------------------------------------------------------------------------*/
  557. #pragma export (IVBDoublePart::isValueOutsideLimits() const,, 2725)
  558. Boolean IVBDoublePart::isValueOutsideLimits () const
  559. {
  560.   return ((value() < lowLimit()) || (value() > highLimit())) ;
  561. }
  562.  
  563. /*------------------------------------------------------------------------------
  564. | IVBDoublePart::isValueWithinLimits                                           |
  565. |                                                                              |
  566. | Return the valueWithinLimits attribute.                                      |
  567. ------------------------------------------------------------------------------*/
  568. #pragma export (IVBDoublePart::isValueWithinLimits() const,, 2726)
  569. Boolean IVBDoublePart::isValueWithinLimits () const
  570. {
  571.   return !isValueOutsideLimits ();
  572. }
  573.  
  574. /*------------------------------------------------------------------------------
  575. | IVBDoublePart::isValueNotZero                                                |
  576. |                                                                              |
  577. | Return the valueNotZero attribute.                                           |
  578. ------------------------------------------------------------------------------*/
  579. #pragma export (IVBDoublePart::isValueNotZero() const,, 2727)
  580. Boolean IVBDoublePart::isValueNotZero () const
  581. {
  582.   return (value() != 0) ;
  583. }
  584.  
  585. /*------------------------------------------------------------------------------
  586. | IVBDoublePart::isValueZero                                                   |
  587. |                                                                              |
  588. | Return the valueZero attribute.                                              |
  589. ------------------------------------------------------------------------------*/
  590. #pragma export (IVBDoublePart::isValueZero() const,, 2728)
  591. Boolean IVBDoublePart::isValueZero () const
  592. {
  593.   return (value() == 0) ;
  594. }
  595.  
  596. /*------------------------------------------------------------------------------
  597. | IVBDoublePart::isValuePositive                                               |
  598. |                                                                              |
  599. | Return the valuePositive attribute.                                          |
  600. ------------------------------------------------------------------------------*/
  601. #pragma export (IVBDoublePart::isValuePositive() const,, 2729)
  602. Boolean IVBDoublePart::isValuePositive () const
  603. {
  604.   return (value() > 0) ;
  605. }
  606.  
  607. /*------------------------------------------------------------------------------
  608. | IVBDoublePart::isValueNegative                                               |
  609. |                                                                              |
  610. | Return the valueNegative attribute.                                          |
  611. ------------------------------------------------------------------------------*/
  612. #pragma export (IVBDoublePart::isValueNegative() const,, 2730)
  613. Boolean IVBDoublePart::isValueNegative () const
  614. {
  615.   return (value() < 0) ;
  616. }
  617.  
  618. /*------------------------------------------------------------------------------
  619. | IVBDoublePart::assignValueToZero                                             |
  620. |                                                                              |
  621. | Assign the value attribute to 0.                                             |
  622. ------------------------------------------------------------------------------*/
  623. #pragma export (IVBDoublePart::assignValueToZero(),, 2731)
  624. IVBDoublePart& IVBDoublePart::assignValueToZero ()
  625. {
  626.   return setValue (0) ;
  627. }
  628.  
  629. /*------------------------------------------------------------------------------
  630. | IVBDoublePart::assignValueToOne                                              |
  631. |                                                                              |
  632. | Assign the value attribute to 1.                                             |
  633. ------------------------------------------------------------------------------*/
  634. #pragma export (IVBDoublePart::assignValueToOne(),, 2732)
  635. IVBDoublePart& IVBDoublePart::assignValueToOne ()
  636. {
  637.   return setValue (1) ;
  638. }
  639.  
  640. /*------------------------------------------------------------------------------
  641. | IVBDoublePart::assignValueToLowLimit                                         |
  642. |                                                                              |
  643. | Assign the value attribute to low limit attribute.                           |
  644. ------------------------------------------------------------------------------*/
  645. #pragma export (IVBDoublePart::assignValueToLowLimit(),, 2733)
  646. IVBDoublePart& IVBDoublePart::assignValueToLowLimit ()
  647. {
  648.   return setValue (lowLimit()) ;
  649. }
  650.  
  651. /*------------------------------------------------------------------------------
  652. | IVBDoublePart::assignValueToHighLimit                                        |
  653. |                                                                              |
  654. | Assign the value attribute to high limit attribute.                          |
  655. ------------------------------------------------------------------------------*/
  656. #pragma export (IVBDoublePart::assignValueToHighLimit(),, 2734)
  657. IVBDoublePart& IVBDoublePart::assignValueToHighLimit ()
  658. {
  659.   return setValue (highLimit()) ;
  660. }
  661.  
  662. /*------------------------------------------------------------------------------
  663. | IVBDoublePart::assignValueToDefault                                          |
  664. |                                                                              |
  665. | Assign the value attribute to default.                                       |
  666. ------------------------------------------------------------------------------*/
  667. #pragma export (IVBDoublePart::assignValueToDefault(),, 2735)
  668. IVBDoublePart& IVBDoublePart::assignValueToDefault ()
  669. {
  670.   return setValue (defaultValue ()) ;
  671. }
  672.  
  673. /*------------------------------------------------------------------------------
  674. | IVBDoublePart::assignValueToRandom                                           |
  675. |                                                                              |
  676. | Assign the value attribute to a pseudo-random number.                        |
  677. ------------------------------------------------------------------------------*/
  678. #pragma export (IVBDoublePart::assignValueToRandom(),, 2736)
  679. IVBDoublePart& IVBDoublePart::assignValueToRandom ()
  680. {
  681.   return setValue (rand ()) ;
  682. }
  683.  
  684. /*------------------------------------------------------------------------------
  685. | IVBDoublePart::copyValueToDefault                                            |
  686. |                                                                              |
  687. | Copy the value attribute to default.                                         |
  688. ------------------------------------------------------------------------------*/
  689. #pragma export (IVBDoublePart::copyValueToDefault(),, 2737)
  690. IVBDoublePart& IVBDoublePart::copyValueToDefault ()
  691. {
  692.   return setDefaultValue (value()) ;
  693. }
  694.  
  695. /*------------------------------------------------------------------------------
  696. | IVBDoublePart::squareValue                                                   |
  697. |                                                                              |
  698. | Square the value attribute.                                                  |
  699. ------------------------------------------------------------------------------*/
  700. #pragma export (IVBDoublePart::squareValue(),, 2738)
  701. IVBDoublePart& IVBDoublePart::squareValue()
  702. {
  703.   return setValue (value() * value()) ;
  704. }
  705.  
  706. /*------------------------------------------------------------------------------
  707. | IVBDoublePart::addValue                                                      |
  708. |                                                                              |
  709. | Perform the add operator to the value attribute.                             |
  710. ------------------------------------------------------------------------------*/
  711. #pragma export (IVBDoublePart::addValue (double),, 2739)
  712. IVBDoublePart& IVBDoublePart::addValue (double addValue)
  713. {
  714.   return setValue (value() + addValue) ;
  715. }
  716.  
  717. /*------------------------------------------------------------------------------
  718. | IVBDoublePart::subtractValue                                                 |
  719. |                                                                              |
  720. | Perform the subtract operator to the value attribute.                        |
  721. ------------------------------------------------------------------------------*/
  722. #pragma export (IVBDoublePart::subtractValue (double),, 2740)
  723. IVBDoublePart& IVBDoublePart::subtractValue (double subtractValue)
  724. {
  725.   return setValue (value() - subtractValue) ;
  726. }
  727.  
  728. /*------------------------------------------------------------------------------
  729. | IVBDoublePart::multiplyValue                                                 |
  730. |                                                                              |
  731. | Perform the multiply operator to the value attribute.                        |
  732. ------------------------------------------------------------------------------*/
  733. #pragma export (IVBDoublePart::multiplyValue (double),, 2741)
  734. IVBDoublePart& IVBDoublePart::multiplyValue (double multiplyValue)
  735. {
  736.   return setValue (value() * multiplyValue) ;
  737. }
  738.  
  739. /*------------------------------------------------------------------------------
  740. | IVBDoublePart::divideValue                                                  |
  741. |                                                                             |
  742. | Perform the divide operator to the value attribute.                         |
  743. ------------------------------------------------------------------------------*/
  744. #pragma export (IVBDoublePart::divideValue (double),, 2742)
  745. IVBDoublePart& IVBDoublePart::divideValue (double divideValue)
  746. {
  747.   if (divideValue)
  748.     return setValue (value() / divideValue) ;
  749.   return *this;
  750. }
  751.  
  752. /*------------------------------------------------------------------------------
  753. | IVBDoublePart::ceilValue                                                     |
  754. |                                                                              |
  755. | Perform the ceil function to the value attribute.                            |
  756. ------------------------------------------------------------------------------*/
  757. #pragma export (IVBDoublePart::ceilValue (),, 2743)
  758. IVBDoublePart& IVBDoublePart::ceilValue ()
  759. {
  760.   return setValue (ceil(value())) ;
  761. }
  762.  
  763. /*------------------------------------------------------------------------------
  764. | IVBDoublePart::floorValue                                                    |
  765. |                                                                              |
  766. | Perform the floor function to the value attribute.                           |
  767. ------------------------------------------------------------------------------*/
  768. #pragma export (IVBDoublePart::floorValue (),, 2744)
  769. IVBDoublePart& IVBDoublePart::floorValue ()
  770. {
  771.   return setValue (floor(value())) ;
  772. }
  773.  
  774. /*------------------------------------------------------------------------------
  775. | IVBDoublePart::assignValueToPI                                               |
  776. |                                                                              |
  777. | Assign the value attribute to PI.                                            |
  778. ------------------------------------------------------------------------------*/
  779. #pragma export (IVBDoublePart::assignValueToPI(),, 2745)
  780. IVBDoublePart& IVBDoublePart::assignValueToPI ()
  781. {
  782.   return setValue (M_PI) ;
  783. }
  784.  
  785. /*------------------------------------------------------------------------------
  786. | IVBDoublePart::assignValueToE                                                |
  787. |                                                                              |
  788. | Assign the value attribute to e.                                             |
  789. ------------------------------------------------------------------------------*/
  790. #pragma export (IVBDoublePart::assignValueToE(),, 2746)
  791. IVBDoublePart& IVBDoublePart::assignValueToE ()
  792. {
  793.   return setValue (M_E) ;
  794. }
  795.  
  796. /*------------------------------------------------------------------------------
  797. | IVBDoublePart::operator == (const IVBDoublePart & aValue)                    |
  798. |                                                                              |
  799. ------------------------------------------------------------------------------*/
  800. #pragma export (IVBDoublePart::operator == (const IVBDoublePart&) const,, 2747)
  801. Boolean IVBDoublePart::
  802.   operator == (const IVBDoublePart& aValue) const
  803. {
  804.   if (value() != aValue.value()) {
  805.     return false;
  806.   } /* endif */
  807.   if (defaultValue() != aValue.defaultValue()) {
  808.     return false;
  809.   } /* endif */
  810.   if (lowLimit() != aValue.lowLimit()) {
  811.     return false;
  812.   } /* endif */
  813.   if (highLimit() != aValue.highLimit()) {
  814.     return false;
  815.   } /* endif */
  816.   return true;
  817. }
  818.  
  819. /*------------------------------------------------------------------------------
  820. | IVBDoublePart::operator != (const IVBDoublePart & aValue)                    |
  821. |                                                                              |
  822. ------------------------------------------------------------------------------*/
  823. #pragma export (IVBDoublePart::operator != (const IVBDoublePart&) const,, 2748)
  824. Boolean IVBDoublePart::
  825.   operator != (const IVBDoublePart& aValue) const
  826. {
  827.   if (value() != aValue.value()) {
  828.     return true;
  829.   } /* endif */
  830.   if (defaultValue() != aValue.defaultValue()) {
  831.     return true;
  832.   } /* endif */
  833.   if (lowLimit() != aValue.lowLimit()) {
  834.     return true;
  835.   } /* endif */
  836.   if (highLimit() != aValue.highLimit()) {
  837.     return true;
  838.   } /* endif */
  839.   return false;
  840. }
  841.  
  842. /*------------------------------------------------------------------------------
  843. | IVBDoublePart::operator == (const IVBDoublePart * aValue)                    |
  844. |                                                                              |
  845. ------------------------------------------------------------------------------*/
  846. #pragma export (IVBDoublePart::operator == (const IVBDoublePart*) const,, 2749)
  847. Boolean IVBDoublePart::
  848.   operator == (const IVBDoublePart* aValue) const
  849. {
  850.   if (value() != aValue->value()) {
  851.     return false;
  852.   } /* endif */
  853.   if (defaultValue() != aValue->defaultValue()) {
  854.     return false;
  855.   } /* endif */
  856.   if (lowLimit() != aValue->lowLimit()) {
  857.     return false;
  858.   } /* endif */
  859.   if (highLimit() != aValue->highLimit()) {
  860.     return false;
  861.   } /* endif */
  862.   return true;
  863. }
  864.  
  865. /*------------------------------------------------------------------------------
  866. | IVBDoublePart::operator != (const IVBDoublePart * aValue)                    |
  867. |                                                                              |
  868. ------------------------------------------------------------------------------*/
  869. #pragma export (IVBDoublePart::operator != (const IVBDoublePart*) const,, 2750)
  870. Boolean IVBDoublePart::
  871.   operator != (const IVBDoublePart* aValue) const
  872. {
  873.   if (value() != aValue->value()) {
  874.     return true;
  875.   } /* endif */
  876.   if (defaultValue() != aValue->defaultValue()) {
  877.     return true;
  878.   } /* endif */
  879.   if (lowLimit() != aValue->lowLimit()) {
  880.     return true;
  881.   } /* endif */
  882.   if (highLimit() != aValue->highLimit()) {
  883.     return true;
  884.   } /* endif */
  885.   return false;
  886. }
  887.