00001 #include <citrus/config.h>
00002
00003 #include <stdio.h>
00004 #include <string.h>
00005
00006 #include <citrus/Dimension.H>
00007
00043 Dimension* theDimensions = 0 ;
00044
00049 void Dimension::p_Dimension( const char* name, const char symbol )
00050 {
00051 m_symbol = symbol ;
00052 if ( name ) {
00053 m_name = new char[ strlen(name) + 1 ] ;
00054 strcpy( m_name, name ) ;
00055 } else {
00056 m_name = 0 ;
00057 }
00058
00059
00060 if ( theDimensions ) {
00061 m_next = theDimensions ;
00062 } else {
00063 m_next = 0 ;
00064 }
00065
00066 theDimensions = this ;
00067 }
00068
00076 Dimension::Dimension( const char* init )
00077 {
00078 char* name ;
00079 char symbol ;
00080 sscanf( init, "%s '%c'", name, &symbol ) ;
00081
00082 p_Dimension( name, symbol ) ;
00083 }
00084
00089 Dimension::Dimension( const char* name, const char symbol )
00090 {
00091 p_Dimension( name, symbol ) ;
00092 }
00093
00099 Dimension::~Dimension()
00100 {
00101 if ( m_name )
00102 delete [] m_name ;
00103
00104 if (theDimensions == this) {
00105 theDimensions = m_next ;
00106 } else {
00107 Dimension* tmp = theDimensions ;
00108 while ( tmp && tmp->m_next != this )
00109 tmp = tmp->m_next ;
00110 tmp->m_next = m_next ;
00111 }
00112 }
00113
00120 Dimension* find_dsym( char sym )
00121 {
00122 Dimension* tmp = theDimensions ;
00123 while ( tmp && tmp->symbol() != sym )
00124 tmp = (Dimension*) tmp->next() ;
00125 return tmp ;
00126 }