source: git/factory/var_intglobal.h @ 362fc67

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: 5.6 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3#ifndef INCL_VAR_INTGLOBAL_H
4#define INCL_VAR_INTGLOBAL_H
5
6//{{{ docu
7//
8// var_intglob.h - header to var_intglob.cc.
9//
10//}}}
11
12// #include "config.h"
13
14class Prim;
15class InternalPoly;
16
17//{{{ template <class T> class PrimitiveArray
18//{{{ docu
19//
20// class PrimitiveArray - primitive array template class.
21//
22// This template implements a dynamical growing array which may
23// have gaps.  As soon as you access any element outside the
24// array the array is resized to contain that element.  Any
25// elements that are created "between" the last existing element
26// and the newly created element are marked as "uninitialized".
27// Using this flag it is possible to check which of the elements
28// previously have been accessed and which not.
29//
30// Consequently, as soon as some element of the array is accessed
31// using operator []() that element will be marked as
32// "initialized".
33//
34// _array: the array itself
35// _initializedFlags: used to keep track of initialized elements
36// _size: the current size of _array
37//
38//}}}
39//{{{ inline method docu
40//
41// int size () const
42// T * array () const
43//
44// size() - return size of array.
45// array() - return pointer to the underlying array.  Use with
46//   care!
47//
48//}}}
49template <class T>
50class PrimitiveArray
51{
52private:
53    T * _array;
54    bool * _initializedFlags;
55    int _size;
56public:
57    PrimitiveArray () : _array( 0 ), _initializedFlags( 0 ), _size( 0 ) {}
58    ~PrimitiveArray () { delete [] _array; delete [] _initializedFlags; }
59
60    T & operator [] ( int i );
61    bool isInitialized ( int i ) const;
62    int getFirstUninitialized () const;
63
64private:
65    int size () const { return _size; }
66    T * array () const { return _array; }
67};
68//}}}
69
70//{{{ class globalVarData
71//{{{ docu
72//
73// class globalVarData - global data associated with a variable.
74//
75// This class holds information which may be associated with any
76// variable: a short name for reading and printing the variable
77// and a long name for printing it only.  The class keeps copies
78// of all long names passed to it (and not only the pointers).
79//
80// _name: short name
81// _longName: long name
82//
83//}}}
84//{{{ inline method docu
85//
86// virtual char & name ()
87// virtual char * longName ()
88// virtual void setLongName ( char * longName )
89//
90// name() - return name
91// longName() - return long name.  No new copy of long name is
92//   created, so be careful with this pointer.
93// setLongName() - set long name to longName.  As mentioned
94//   before, a new copy is created.
95//
96//}}}
97class globalVarData
98{
99private:
100    char _name;
101    char * _longName;
102
103    void initializeLongName( char * );
104
105public:
106    // constructors, destructors, assignment
107    globalVarData ( char name = 0, char * longName = 0 );
108    globalVarData ( const globalVarData & );
109
110    virtual ~globalVarData () { delete [] _longName; }
111
112    globalVarData & operator = ( const globalVarData & );
113
114    // selectors
115    virtual char & name () { return _name; }
116    virtual char * longName () const { return _longName; }
117    virtual void setLongName ( char * longName )
118        { initializeLongName( longName ); }
119
120    // comparisons
121    friend bool operator == ( const globalVarData &, const globalVarData & );
122    friend bool operator != ( const globalVarData &, const globalVarData & );
123};
124//}}}
125
126//{{{ class globalAlgData : public globalVarData
127//{{{ docu
128//
129// class globalAlgData - global data associated with algebraic
130//   variables.
131//
132// This class is derived from class globalVarData.  It adds the
133// information on the minimal polynomial associated with the
134// algebraic variable and a flag whether arithmetic operations
135// should reduce module the minimal polynomial or not.
136//
137// _mipo: pointer to the minimal polynomial.  This class does
138//   merely keeps the pointer.  It neither deletes it nor calls
139//   any methods of the InternalPoly which it references.
140// _reduce: reduce flag
141//
142//}}}
143//{{{ inline method docu
144//
145// InternalPoly * & mipo ()
146// bool & reduce ()
147//
148// mipo() - return the minimal polynomial
149// reduce() - return the reduce flag
150//
151//}}}
152class globalAlgData : public globalVarData
153{
154private:
155    InternalPoly * _mipo;
156    bool _reduce;
157
158public:
159    // constructors, destructors, assignment
160    globalAlgData ( char name = 0, char * longName = 0, InternalPoly * mipo = 0, bool reduce = false )
161        : globalVarData( name, longName ), _mipo( mipo ), _reduce( reduce ) {}
162    globalAlgData ( const globalAlgData & d )
163        : globalVarData( d ), _mipo( d._mipo ), _reduce( d._reduce ) {}
164
165    globalAlgData & operator = ( const globalAlgData & );
166
167    // selectors
168    InternalPoly * & mipo () { return _mipo; }
169    bool & reduce () { return _reduce; }
170};
171//}}}
172
173//{{{ class globalAlgNumData : public globalVarData
174//{{{ docu
175//
176// class globalAlgData - global data associated with algebraic
177//   variables.
178//
179// This class is derived from class globalVarData.  It adds the
180// information on the prim element associated with the variable.
181//
182// _prim: pointer to the prim element.  This class does
183//   merely keeps the pointer.  It neither deletes it nor calls
184//   any methods of the Prim which it references.
185//
186//}}}
187//{{{ inline method docu
188//
189// Prim * & prim ()
190//
191// prim() - return the prim element
192//
193//}}}
194class globalAlgNumData : public globalVarData
195{
196private:
197    Prim * _prim;
198
199public:
200    // constructors, destructors, assignment
201    globalAlgNumData ( char name = 0, char * longName = 0, Prim * prim = 0 )
202        : globalVarData( name, longName ), _prim( prim ) {}
203    globalAlgNumData ( const globalAlgNumData & d )
204        : globalVarData( d ), _prim( d._prim ) {}
205
206    globalAlgNumData & operator = ( const globalAlgNumData & );
207
208    // selectors
209    Prim * & prim () { return _prim; }
210};
211//}}}
212
213#endif /* ! INCL_VAR_INTGLOBAL_H */
Note: See TracBrowser for help on using the repository browser.