00001 #ifndef _IT_BUS_INTEGER_H_
00002 #define _IT_BUS_INTEGER_H_
00003
00004
00005
00006
00007 #include <it_cal/types.h>
00008 #include <it_dsa/fixed_point.h>
00009 #include <it_bus/exception.h>
00010 #include <it_bus/api_defines.h>
00011 #include <it_bus/any_simple_type.h>
00012
00013 namespace IT_Reflect
00014 {
00015 class Reflection;
00016 template <class T> class ValueRef;
00017 }
00018
00019 namespace IT_Bus
00020 {
00027 class IT_AFC_API Integer : public AnySimpleType
00028 {
00029 public:
00030 typedef IT_Reflect::ValueRef<IT_Bus::Integer> IT_ReflectionType;
00031
00035 Integer(
00036 ) throw(());
00037
00043 Integer(
00044 short value
00045 ) throw(());
00046
00052 Integer(
00053 unsigned short value
00054 ) throw(());
00055
00061 Integer(
00062 int value
00063 ) throw(());
00064
00070 Integer(
00071 unsigned int value
00072 ) throw(());
00073
00079 Integer(
00080 long value
00081 ) throw(());
00082
00088 Integer(
00089 unsigned long value
00090 ) throw(());
00091
00092 #if !IT_LONG_LONG_IS_SAME_AS_LONG
00093
00098 Integer(
00099 IT_LongLong value
00100 ) throw(());
00101
00107 Integer(
00108 IT_ULongLong value
00109 ) throw(());
00110 #endif
00111
00118 Integer(
00119 const char* value,
00120 bool truncate = false
00121 ) throw((IT_Bus::Exception));
00122
00129 Integer(
00130 const String& value,
00131 bool truncate = false
00132 ) throw((IT_Bus::Exception));
00133
00140 Integer(
00141 const Decimal& value,
00142 bool truncate = false
00143 ) throw((IT_Bus::Exception));
00144
00150 Integer(
00151 const Integer& copy
00152 ) throw(());
00153
00157 Integer&
00158 operator=(
00159 const Integer& rhs
00160 ) throw(());
00161
00165 Integer&
00166 operator+=(
00167 const Integer& rhs
00168 ) throw((IT_Bus::Exception));
00169
00173 Integer&
00174 operator-=(
00175 const Integer& rhs
00176 ) throw((IT_Bus::Exception));
00177
00181 Integer&
00182 operator*=(
00183 const Integer& rhs
00184 ) throw((IT_Bus::Exception));
00185
00189 Integer&
00190 operator/=(
00191 const Integer& rhs
00192 ) throw((IT_Bus::Exception));
00193
00197 Integer&
00198 operator%=(
00199 const Integer& rhs
00200 ) throw((IT_Bus::Exception));
00201
00205 Integer&
00206 operator++(
00207 ) throw((IT_Bus::Exception));
00208
00212 const Integer
00213 operator++(
00214 int
00215 ) throw((IT_Bus::Exception));
00216
00220 Integer&
00221 operator--(
00222 ) throw((IT_Bus::Exception));
00223
00227 const Integer
00228 operator--(
00229 int
00230 ) throw((IT_Bus::Exception));
00231
00235 bool
00236 is_negative(
00237 ) const throw(());
00238
00242 bool
00243 is_positive(
00244 ) const throw(());
00245
00249 bool
00250 is_non_negative(
00251 ) const throw(());
00252
00256 bool
00257 is_non_positive(
00258 ) const throw(());
00259
00272 int
00273 compare(
00274 const Integer& other
00275 ) const throw(());
00276
00282 const Decimal&
00283 get_value(
00284 ) const throw(());
00285
00298 void
00299 set_value(
00300 const Decimal& value,
00301 bool truncate = false
00302 ) throw((IT_Bus::Exception));
00303
00309 String
00310 to_string(
00311 ) const throw(());
00312
00319 static bool
00320 is_valid_integer(
00321 const Decimal& value
00322 ) throw(());
00323
00324
00325
00326 virtual AnyType&
00327 copy(
00328 const AnyType& copy
00329 );
00330
00338 virtual AnyType::Kind
00339 get_kind() const;
00340
00347 virtual const QName&
00348 get_type() const;
00349
00350 virtual IT_Reflect::Reflection*
00351 get_reflection(
00352 ) throw((IT_Reflect::ReflectException));
00353
00354 virtual const IT_Reflect::Reflection*
00355 get_reflection(
00356 ) const throw((IT_Reflect::ReflectException));
00357
00358
00359
00360 virtual void
00361 write_value(
00362 AnySimpleTypeWriter& writer
00363 ) const throw((IT_Bus::SerializationException));
00364
00365 virtual void
00366 read_value(
00367 AnySimpleTypeReader& reader
00368 ) throw((IT_Bus::DeserializationException));
00369
00370
00371
00372 static const QName&
00373 get_static_type();
00374
00375 protected:
00383 virtual void
00384 validate(
00385 const Decimal& value
00386 ) const throw((IT_Bus::Exception));
00387
00395 static Decimal
00396 from_string(
00397 const char* value,
00398 bool truncate = false
00399 ) throw((IT_Bus::Exception));
00400
00407 static Decimal
00408 from_signed(
00409 IT_LongLong value
00410 ) throw(());
00411
00418 static Decimal
00419 from_unsigned(
00420 IT_ULongLong value
00421 ) throw(());
00422
00428 static void
00429 validate_integer(
00430 const Decimal& value
00431 ) throw((IT_Bus::Exception));
00432
00436 Decimal m_value;
00437 };
00438
00445 class IT_AFC_API NonPositiveInteger : public Integer
00446 {
00447 public:
00448 typedef IT_Reflect::ValueRef<IT_Bus::NonPositiveInteger>
00449 IT_ReflectionType;
00450
00454 NonPositiveInteger(
00455 ) throw(());
00456
00462 NonPositiveInteger(
00463 short value
00464 ) throw((IT_Bus::Exception));
00465
00471 NonPositiveInteger(
00472 unsigned short value
00473 ) throw((IT_Bus::Exception));
00474
00480 NonPositiveInteger(
00481 int value
00482 ) throw((IT_Bus::Exception));
00483
00489 NonPositiveInteger(
00490 unsigned int value
00491 ) throw((IT_Bus::Exception));
00492
00498 NonPositiveInteger(
00499 long value
00500 ) throw((IT_Bus::Exception));
00501
00507 NonPositiveInteger(
00508 unsigned long value
00509 ) throw((IT_Bus::Exception));
00510
00511 #if !IT_LONG_LONG_IS_SAME_AS_LONG
00512
00517 NonPositiveInteger(
00518 IT_LongLong value
00519 ) throw((IT_Bus::Exception));
00520
00526 NonPositiveInteger(
00527 IT_ULongLong value
00528 ) throw((IT_Bus::Exception));
00529 #endif
00530
00537 NonPositiveInteger(
00538 const char* value,
00539 bool truncate = false
00540 ) throw((IT_Bus::Exception));
00541
00548 NonPositiveInteger(
00549 const String& value,
00550 bool truncate = false
00551 ) throw((IT_Bus::Exception));
00552
00559 NonPositiveInteger(
00560 const Decimal& value,
00561 bool truncate = false
00562 ) throw((IT_Bus::Exception));
00563
00569 NonPositiveInteger(
00570 const Integer& copy
00571 ) throw((IT_Bus::Exception));
00572
00576 NonPositiveInteger(
00577 const NonPositiveInteger& copy
00578 ) throw(());
00579
00583 NonPositiveInteger&
00584 operator=(
00585 short value
00586 ) throw((IT_Bus::Exception));
00587
00591 NonPositiveInteger&
00592 operator=(
00593 unsigned short value
00594 ) throw((IT_Bus::Exception));
00595
00599 NonPositiveInteger&
00600 operator=(
00601 int value
00602 ) throw((IT_Bus::Exception));
00603
00607 NonPositiveInteger&
00608 operator=(
00609 unsigned int value
00610 ) throw((IT_Bus::Exception));
00611
00615 NonPositiveInteger&
00616 operator=(
00617 long value
00618 ) throw((IT_Bus::Exception));
00619
00623 NonPositiveInteger&
00624 operator=(
00625 unsigned long value
00626 ) throw((IT_Bus::Exception));
00627
00628 #if !IT_LONG_LONG_IS_SAME_AS_LONG
00629
00632 NonPositiveInteger&
00633 operator=(
00634 IT_LongLong value
00635 ) throw((IT_Bus::Exception));
00636
00640 NonPositiveInteger&
00641 operator=(
00642 IT_ULongLong value
00643 ) throw((IT_Bus::Exception));
00644 #endif
00645
00649 NonPositiveInteger&
00650 operator=(
00651 const Integer& rhs
00652 ) throw((IT_Bus::Exception));
00653
00657 NonPositiveInteger&
00658 operator=(
00659 const NonPositiveInteger& rhs
00660 ) throw(());
00661
00668 static bool
00669 is_valid_non_positive_integer(
00670 const Decimal& value
00671 ) throw(());
00672
00673
00674
00675 virtual AnyType&
00676 copy(
00677 const AnyType& copy
00678 );
00679
00685 virtual const QName&
00686 get_type() const;
00687
00688 virtual IT_Reflect::Reflection*
00689 get_reflection(
00690 ) throw((IT_Reflect::ReflectException));
00691
00692 virtual const IT_Reflect::Reflection*
00693 get_reflection(
00694 ) const throw((IT_Reflect::ReflectException));
00695
00696
00697
00698 static const QName&
00699 get_static_type();
00700
00701 protected:
00709 virtual void
00710 validate(
00711 const Decimal& value
00712 ) const throw((IT_Bus::Exception));
00713
00720 static void
00721 validate_non_positive_integer(
00722 const Decimal& value
00723 ) throw((IT_Bus::Exception));
00724 };
00725
00732 class IT_AFC_API NegativeInteger : public NonPositiveInteger
00733 {
00734 public:
00735 typedef IT_Reflect::ValueRef<IT_Bus::NegativeInteger>
00736 IT_ReflectionType;
00737
00741 NegativeInteger(
00742 ) throw(());
00743
00749 NegativeInteger(
00750 short value
00751 ) throw((IT_Bus::Exception));
00752
00758 NegativeInteger(
00759 int value
00760 ) throw((IT_Bus::Exception));
00761
00767 NegativeInteger(
00768 long value
00769 ) throw((IT_Bus::Exception));
00770
00771 #if !IT_LONG_LONG_IS_SAME_AS_LONG
00772
00777 NegativeInteger(
00778 IT_LongLong value
00779 ) throw((IT_Bus::Exception));
00780 #endif
00781
00788 NegativeInteger(
00789 const char* value,
00790 bool truncate = false
00791 ) throw((IT_Bus::Exception));
00792
00799 NegativeInteger(
00800 const String& value,
00801 bool truncate = false
00802 ) throw((IT_Bus::Exception));
00803
00810 NegativeInteger(
00811 const Decimal& value,
00812 bool truncate = false
00813 ) throw((IT_Bus::Exception));
00814
00820 NegativeInteger(
00821 const Integer& copy
00822 ) throw((IT_Bus::Exception));
00823
00827 NegativeInteger(
00828 const NegativeInteger& copy
00829 ) throw(());
00830
00834 NegativeInteger&
00835 operator=(
00836 short value
00837 ) throw((IT_Bus::Exception));
00838
00842 NegativeInteger&
00843 operator=(
00844 int value
00845 ) throw((IT_Bus::Exception));
00846
00850 NegativeInteger&
00851 operator=(
00852 long value
00853 ) throw((IT_Bus::Exception));
00854
00855 #if !IT_LONG_LONG_IS_SAME_AS_LONG
00856
00859 NegativeInteger&
00860 operator=(
00861 IT_LongLong value
00862 ) throw((IT_Bus::Exception));
00863 #endif
00864
00868 NegativeInteger&
00869 operator=(
00870 const Integer& rhs
00871 ) throw((IT_Bus::Exception));
00872
00876 NegativeInteger&
00877 operator=(
00878 const NegativeInteger& rhs
00879 ) throw(());
00880
00886 static bool
00887 is_valid_negative_integer(
00888 const Decimal& value
00889 ) throw(());
00890
00891
00892
00893 virtual AnyType&
00894 copy(
00895 const AnyType& copy
00896 );
00897
00903 virtual const QName&
00904 get_type() const;
00905
00906 virtual IT_Reflect::Reflection*
00907 get_reflection(
00908 ) throw((IT_Reflect::ReflectException));
00909
00910 virtual const IT_Reflect::Reflection*
00911 get_reflection(
00912 ) const throw((IT_Reflect::ReflectException));
00913
00914
00915
00916 static const QName&
00917 get_static_type();
00918
00919 protected:
00927 virtual void
00928 validate(
00929 const Decimal& value
00930 ) const throw((IT_Bus::Exception));
00931
00938 static void
00939 validate_negative_integer(
00940 const Decimal& value
00941 ) throw((IT_Bus::Exception));
00942 };
00943
00950 class IT_AFC_API NonNegativeInteger : public Integer
00951 {
00952 public:
00953 typedef IT_Reflect::ValueRef<IT_Bus::NonNegativeInteger>
00954 IT_ReflectionType;
00955
00959 NonNegativeInteger(
00960 ) throw(());
00961
00967 NonNegativeInteger(
00968 short value
00969 ) throw((IT_Bus::Exception));
00970
00976 NonNegativeInteger(
00977 unsigned short value
00978 ) throw(());
00979
00985 NonNegativeInteger(
00986 int value
00987 ) throw((IT_Bus::Exception));
00988
00994 NonNegativeInteger(
00995 unsigned int value
00996 ) throw(());
00997
01003 NonNegativeInteger(
01004 long value
01005 ) throw((IT_Bus::Exception));
01006
01012 NonNegativeInteger(
01013 unsigned long value
01014 ) throw(());
01015
01016 #if !IT_LONG_LONG_IS_SAME_AS_LONG
01017
01022 NonNegativeInteger(
01023 IT_LongLong value
01024 ) throw((IT_Bus::Exception));
01025
01031 NonNegativeInteger(
01032 IT_ULongLong value
01033 ) throw(());
01034 #endif
01035
01042 NonNegativeInteger(
01043 const char* value,
01044 bool truncate = false
01045 ) throw((IT_Bus::Exception));
01046
01053 NonNegativeInteger(
01054 const String& value,
01055 bool truncate = false
01056 ) throw((IT_Bus::Exception));
01057
01064 NonNegativeInteger(
01065 const Decimal& value,
01066 bool truncate = false
01067 ) throw((IT_Bus::Exception));
01068
01074 NonNegativeInteger(
01075 const Integer& copy
01076 ) throw((IT_Bus::Exception));
01077
01081 NonNegativeInteger(
01082 const NonNegativeInteger& copy
01083 ) throw(());
01084
01088 NonNegativeInteger&
01089 operator=(
01090 short value
01091 ) throw((IT_Bus::Exception));
01092
01096 NonNegativeInteger&
01097 operator=(
01098 unsigned short value
01099 ) throw(());
01100
01104 NonNegativeInteger&
01105 operator=(
01106 int value
01107 ) throw((IT_Bus::Exception));
01108
01112 NonNegativeInteger&
01113 operator=(
01114 unsigned int value
01115 ) throw(());
01116
01120 NonNegativeInteger&
01121 operator=(
01122 long value
01123 ) throw((IT_Bus::Exception));
01124
01128 NonNegativeInteger&
01129 operator=(
01130 unsigned long value
01131 ) throw(());
01132
01133 #if !IT_LONG_LONG_IS_SAME_AS_LONG
01134
01137 NonNegativeInteger&
01138 operator=(
01139 IT_LongLong value
01140 ) throw((IT_Bus::Exception));
01141
01145 NonNegativeInteger&
01146 operator=(
01147 IT_ULongLong value
01148 ) throw(());
01149 #endif
01150
01154 NonNegativeInteger&
01155 operator=(
01156 const Integer& rhs
01157 ) throw((IT_Bus::Exception));
01158
01162 NonNegativeInteger&
01163 operator=(
01164 const NonNegativeInteger& rhs
01165 ) throw(());
01166
01172 static bool
01173 is_valid_non_negative_integer(
01174 const Decimal& value
01175 ) throw(());
01176
01177
01178
01179 virtual AnyType&
01180 copy(
01181 const AnyType& copy
01182 );
01183
01189 virtual const QName&
01190 get_type() const;
01191
01192 virtual IT_Reflect::Reflection*
01193 get_reflection(
01194 ) throw((IT_Reflect::ReflectException));
01195
01196 virtual const IT_Reflect::Reflection*
01197 get_reflection(
01198 ) const throw((IT_Reflect::ReflectException));
01199
01200
01201
01202 static const QName&
01203 get_static_type();
01204
01205 protected:
01213 virtual void
01214 validate(
01215 const Decimal& value
01216 ) const throw((IT_Bus::Exception));
01217
01224 static void
01225 validate_non_negative_integer(
01226 const Decimal& value
01227 ) throw((IT_Bus::Exception));
01228 };
01229
01236 class IT_AFC_API PositiveInteger : public NonNegativeInteger
01237 {
01238 public:
01239 typedef IT_Reflect::ValueRef<IT_Bus::PositiveInteger>
01240 IT_ReflectionType;
01241
01245 PositiveInteger(
01246 ) throw(());
01247
01253 PositiveInteger(
01254 short value
01255 ) throw((IT_Bus::Exception));
01256
01262 PositiveInteger(
01263 unsigned short value
01264 ) throw((IT_Bus::Exception));
01265
01271 PositiveInteger(
01272 int value
01273 ) throw((IT_Bus::Exception));
01274
01280 PositiveInteger(
01281 unsigned int value
01282 ) throw((IT_Bus::Exception));
01283
01289 PositiveInteger(
01290 long value
01291 ) throw((IT_Bus::Exception));
01292
01298 PositiveInteger(
01299 unsigned long value
01300 ) throw((IT_Bus::Exception));
01301
01302 #if !IT_LONG_LONG_IS_SAME_AS_LONG
01303
01308 PositiveInteger(
01309 IT_LongLong value
01310 ) throw((IT_Bus::Exception));
01311
01317 PositiveInteger(
01318 IT_ULongLong value
01319 ) throw((IT_Bus::Exception));
01320 #endif
01321
01328 PositiveInteger(
01329 const char* value,
01330 bool truncate = false
01331 ) throw((IT_Bus::Exception));
01332
01339 PositiveInteger(
01340 const String& value,
01341 bool truncate = false
01342 ) throw((IT_Bus::Exception));
01343
01350 PositiveInteger(
01351 const Decimal& value,
01352 bool truncate = false
01353 ) throw((IT_Bus::Exception));
01354
01360 PositiveInteger(
01361 const Integer& copy
01362 ) throw((IT_Bus::Exception));
01363
01369 PositiveInteger(
01370 const PositiveInteger& copy
01371 ) throw(());
01372
01376 PositiveInteger&
01377 operator=(
01378 short value
01379 ) throw((IT_Bus::Exception));
01380
01384 PositiveInteger&
01385 operator=(
01386 unsigned short value
01387 ) throw((IT_Bus::Exception));
01388
01392 PositiveInteger&
01393 operator=(
01394 int value
01395 ) throw((IT_Bus::Exception));
01396
01400 PositiveInteger&
01401 operator=(
01402 unsigned int value
01403 ) throw((IT_Bus::Exception));
01404
01408 PositiveInteger&
01409 operator=(
01410 long value
01411 ) throw((IT_Bus::Exception));
01412
01416 PositiveInteger&
01417 operator=(
01418 unsigned long value
01419 ) throw((IT_Bus::Exception));
01420
01421 #if !IT_LONG_LONG_IS_SAME_AS_LONG
01422
01425 PositiveInteger&
01426 operator=(
01427 IT_LongLong value
01428 ) throw((IT_Bus::Exception));
01429
01433 PositiveInteger&
01434 operator=(
01435 IT_ULongLong value
01436 ) throw((IT_Bus::Exception));
01437 #endif
01438
01442 PositiveInteger&
01443 operator=(
01444 const Integer& rhs
01445 ) throw((IT_Bus::Exception));
01446
01450 PositiveInteger&
01451 operator=(
01452 const PositiveInteger& rhs
01453 ) throw(());
01454
01460 static bool
01461 is_valid_positive_integer(
01462 const Decimal& value
01463 ) throw(());
01464
01465
01466
01467 virtual AnyType&
01468 copy(
01469 const AnyType& copy
01470 );
01471
01477 virtual const QName&
01478 get_type() const;
01479
01480 virtual IT_Reflect::Reflection*
01481 get_reflection(
01482 ) throw((IT_Reflect::ReflectException));
01483
01484 virtual const IT_Reflect::Reflection*
01485 get_reflection(
01486 ) const throw((IT_Reflect::ReflectException));
01487
01488
01489
01490 static const QName&
01491 get_static_type();
01492
01493 protected:
01501 virtual void
01502 validate(
01503 const Decimal& value
01504 ) const throw((IT_Bus::Exception));
01505
01512 static void
01513 validate_positive_integer(
01514 const Decimal& value
01515 ) throw((IT_Bus::Exception));
01516 };
01517
01521 extern IT_AFC_API bool
01522 operator==(
01523 const Integer& lhs,
01524 const Integer& rhs
01525 ) throw(());
01526
01530 extern IT_AFC_API bool
01531 operator!=(
01532 const Integer& lhs,
01533 const Integer& rhs
01534 ) throw(());
01535
01539 extern IT_AFC_API bool
01540 operator<(
01541 const Integer& lhs,
01542 const Integer& rhs
01543 ) throw(());
01544
01548 extern IT_AFC_API bool
01549 operator>(
01550 const Integer& lhs,
01551 const Integer& rhs
01552 ) throw(());
01553
01557 extern IT_AFC_API bool
01558 operator>=(
01559 const Integer& lhs,
01560 const Integer& rhs
01561 ) throw(());
01562
01566 extern IT_AFC_API bool
01567 operator<=(
01568 const Integer& lhs,
01569 const Integer& rhs
01570 ) throw(());
01571
01575 extern IT_AFC_API Integer
01576 operator+(
01577 const Integer& rhs
01578 ) throw(());
01579
01583 extern IT_AFC_API Integer
01584 operator-(
01585 const Integer& rhs
01586 ) throw(());
01587
01591 extern IT_AFC_API bool
01592 operator!(
01593 const Integer& rhs
01594 ) throw(());
01595
01599 extern IT_AFC_API Integer
01600 operator+(
01601 const Integer& lhs,
01602 const Integer& rhs
01603 ) throw((IT_Bus::Exception));
01604
01608 extern IT_AFC_API Integer
01609 operator-(
01610 const Integer& lhs,
01611 const Integer& rhs
01612 ) throw((IT_Bus::Exception));
01613
01617 extern IT_AFC_API Integer
01618 operator*(
01619 const Integer& lhs,
01620 const Integer& rhs
01621 ) throw((IT_Bus::Exception));
01622
01626 extern IT_AFC_API Integer
01627 operator/(
01628 const Integer& lhs,
01629 const Integer& rhs
01630 ) throw((IT_Bus::Exception));
01631
01635 extern IT_AFC_API Integer
01636 operator%(
01637 const Integer& lhs,
01638 const Integer& rhs
01639 ) throw((IT_Bus::Exception));
01640
01641 }
01642
01643
01644 #endif