source: git/factory/var_intglobal.h @ e4fe2b

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