source: git/factory/include/factory/templates/ftmpl_factor.h @ 4e2385

spielwiese
Last change on this file since 4e2385 was 362fc67, checked in by Martin Lee <martinlee84@…>, 12 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
19template <class T>
20class Factor {
21private:
22    T _factor;
23    int _exp;
24public:
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
43template <class T> int
44operator== ( const Factor<T>&, const Factor<T>& );
45
46#ifndef NOSTREAMIO
47template <class T>
48OSTREAM& 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.