00001 #ifndef DIMENSIOGROUP_H 00002 #define DIMENSIOGROUP_H 00003 00004 #include <stdio.h> 00005 #include <list> 00006 #include <vector> 00007 00008 #include <citrus/Dimension.H> 00009 00010 class Unit ; 00011 00012 class DimensionPower { 00013 public: 00015 DimensionPower() 00016 : m_dim(0), m_pwr(0) { } ; 00018 DimensionPower( Dimension* dim, int pwr ) 00019 : m_dim(dim), m_pwr(pwr) { } ; 00021 Dimension* m_dim ; 00023 int m_pwr ; 00025 bool operator ==( const DimensionPower& other ) const 00026 { return ( m_dim == other.m_dim && m_pwr == other.m_pwr ) ; } ; 00028 DimensionPower& operator =( const DimensionPower& other ) 00029 { m_dim = other.m_dim ; m_pwr = other.m_pwr ; return *this ; } ; 00031 bool isNull() const { return m_dim == 0 ; } 00032 static void print( const vector<DimensionPower>& dpwr, FILE* f=stderr) ; 00033 } ; 00034 00035 class DimensionGroup { 00036 protected: 00038 vector<DimensionPower> m_dims ; 00040 list<Unit*> m_children ; 00042 char* m_name ; 00044 DimensionGroup* m_next ; 00045 00046 void p_add( Unit* ) ; 00047 void p_remove( Unit* ) ; 00048 00050 friend class Unit ; 00052 friend class Quantity ; 00053 static DimensionGroup* theDimensionGroups ; 00054 public: 00055 DimensionGroup( const char* name = 0 ) ; 00056 DimensionGroup( const char* name, vector<DimensionPower> dims ) ; 00057 ~DimensionGroup() ; 00058 00059 void setDimensions( vector<DimensionPower> dims ) ; 00061 DimensionGroup* next() const 00062 { return m_next ; } ; 00063 void name( const char* ) ; 00065 char* name() const 00066 { return m_name ; } ; 00067 00068 bool operator == (const vector<DimensionPower>& pwr) ; 00070 bool operator == (DimensionGroup other) 00071 { return !strcmp( m_name, other.m_name ) ; } ; 00073 vector<DimensionPower>::const_iterator dpwrBegin() const { return m_dims.begin(); } 00075 vector<DimensionPower>::const_iterator dpwrEnd() const { return m_dims.end(); } 00077 list<Unit*>::const_iterator unitBegin() const { return m_children.begin(); } 00079 list<Unit*>::const_iterator unitEnd() const { return m_children.end(); } 00081 vector<DimensionPower>::iterator dpwrBegin() { return m_dims.begin(); } 00083 vector<DimensionPower>::iterator dpwrEnd() { return m_dims.end(); } 00085 list<Unit*>::iterator unitBegin() { return m_children.begin(); } 00087 list<Unit*>::iterator unitEnd() { return m_children.end(); } 00088 00089 static DimensionGroup* find( const char* dgrp_name ) ; 00090 static DimensionGroup* find( const vector< DimensionPower>& dpwr ) ; 00091 00093 static const DimensionGroup* first() { return theDimensionGroups ; } 00094 } ; 00095 00096 vector<DimensionPower>::const_iterator find_dimn( Dimension* dimn, 00097 const vector<DimensionPower>& dpwr ) ; 00098 vector<DimensionPower>::iterator find_dimn( Dimension* dimn, 00099 vector<DimensionPower>& dpwr ) ; 00100 00101 bool areDimensionsMatched( const vector<DimensionPower>& d1, 00102 const vector<DimensionPower>& d2 ) ; 00103 #endif // DIMENSIONGROUP_H
![]() |
C++ Reference Manual | 20010520 |