jengelh-datetimespielwiese
Last change
on this file since 362fc67 was
362fc67,
checked in by Martin Lee <martinlee84@…>, 11 years ago
|
chg: remove $Id$
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[6ab5981] | 1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
[684544] | 2 | |
---|
| 3 | #ifndef INCL_FACTOR_H |
---|
| 4 | #define INCL_FACTOR_H |
---|
| 5 | |
---|
[e4fe2b] | 6 | // #include <factory/factoryconf.h> |
---|
[8c0163] | 7 | |
---|
[175e355] | 8 | #ifndef NOSTREAMIO |
---|
[1dc616] | 9 | #ifdef HAVE_IOSTREAM |
---|
| 10 | #include <iostream> |
---|
[181148] | 11 | #define OSTREAM std::ostream |
---|
[1dc616] | 12 | #elif defined(HAVE_IOSTREAM_H) |
---|
[684544] | 13 | #include <iostream.h> |
---|
[181148] | 14 | #define OSTREAM ostream |
---|
[1dc616] | 15 | #endif |
---|
[175e355] | 16 | #endif /* NOSTREAMIO */ |
---|
[684544] | 17 | |
---|
| 18 | |
---|
| 19 | template <class T> |
---|
| 20 | class Factor { |
---|
| 21 | private: |
---|
| 22 | T _factor; |
---|
| 23 | int _exp; |
---|
| 24 | public: |
---|
| 25 | Factor() : _factor(1), _exp(0) {} |
---|
| 26 | Factor( const Factor<T> & f ) : _factor(f._factor), _exp(f._exp) {} |
---|
| 27 | Factor( const T & f, int e ) : _factor(f), _exp(e) {} |
---|
| 28 | Factor( const T & f ) : _factor(f), _exp(1) {} |
---|
| 29 | ~Factor() {} |
---|
| 30 | Factor<T>& operator= ( const Factor<T>& ); |
---|
| 31 | Factor<T>& operator= ( const T& ); |
---|
| 32 | T factor() const { return _factor; } |
---|
| 33 | int exp() const { return _exp; } |
---|
| 34 | T value() const { return power( _factor, _exp ); } |
---|
| 35 | Factor<T>& operator+= ( int i ) { _exp += i; return *this; } |
---|
| 36 | Factor<T>& operator*= ( int i ) { _exp *= i; return *this; } |
---|
| 37 | Factor<T>& operator*= ( const T & f ) { _factor *= f; return *this; } |
---|
[175e355] | 38 | #ifndef NOSTREAMIO |
---|
[181148] | 39 | void print ( OSTREAM& ) const; |
---|
[175e355] | 40 | #endif /* NOSTREAMIO */ |
---|
[684544] | 41 | }; |
---|
| 42 | |
---|
[d2b5a7] | 43 | template <class T> int |
---|
| 44 | operator== ( const Factor<T>&, const Factor<T>& ); |
---|
| 45 | |
---|
[175e355] | 46 | #ifndef NOSTREAMIO |
---|
[684544] | 47 | template <class T> |
---|
[181148] | 48 | OSTREAM& operator<< ( OSTREAM & os, const Factor<T> & f ); |
---|
[175e355] | 49 | #endif /* NOSTREAMIO */ |
---|
[684544] | 50 | |
---|
[6ab5981] | 51 | #endif /* ! INCL_FACTOR_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.