jengelh-datetimespielwiese
Last change
on this file since b1d287 was
362fc67,
checked in by Martin Lee <martinlee84@…>, 11 years ago
|
chg: remove $Id$
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | |
---|
3 | #ifndef INCL_FACTOR_H |
---|
4 | #define INCL_FACTOR_H |
---|
5 | |
---|
6 | // #include <factory/factoryconf.h> |
---|
7 | |
---|
8 | #ifndef NOSTREAMIO |
---|
9 | #ifdef HAVE_IOSTREAM |
---|
10 | #include <iostream> |
---|
11 | #define OSTREAM std::ostream |
---|
12 | #elif defined(HAVE_IOSTREAM_H) |
---|
13 | #include <iostream.h> |
---|
14 | #define OSTREAM ostream |
---|
15 | #endif |
---|
16 | #endif /* NOSTREAMIO */ |
---|
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; } |
---|
38 | #ifndef NOSTREAMIO |
---|
39 | void print ( OSTREAM& ) const; |
---|
40 | #endif /* NOSTREAMIO */ |
---|
41 | }; |
---|
42 | |
---|
43 | template <class T> int |
---|
44 | operator== ( const Factor<T>&, const Factor<T>& ); |
---|
45 | |
---|
46 | #ifndef NOSTREAMIO |
---|
47 | template <class T> |
---|
48 | OSTREAM& operator<< ( OSTREAM & os, const Factor<T> & f ); |
---|
49 | #endif /* NOSTREAMIO */ |
---|
50 | |
---|
51 | #endif /* ! INCL_FACTOR_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.