source: git/factory/cf_iter_inline.cc @ 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: 3.2 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id$ */
3
4//{{{ docu
5//
6// cf_iter_inline.cc - definition of configurable inline
7//   `CFIterator' methods.
8//
9// Hierarchy: canonicalform, utility class
10//
11// Header file: cf_iter.h
12//
13// See `cf_inline.cc' for a description of "configurable inline
14// methods".
15//
16//}}}
17
18// check whether we are included or translated and
19// define `INCL_CF_ITER_INLINE_CC' if we are included
20#ifdef INCL_CF_ITER_H
21#define INCL_CF_ITER_INLINE_CC
22#endif
23
24#include "config.h"
25
26#include "cf_assert.h"
27
28// regular include file
29#include "canonicalform.h"
30
31// temporarily switch off `CF_USE_INLINE' and include
32// `cf_iter.h' if we are being translated.
33// `CF_USE_INLINE_SAVE' is used to save the state of
34// `CF_USE_INLINE'.  It is unset after use.
35#ifndef INCL_CF_ITER_INLINE_CC
36#ifdef CF_USE_INLINE
37#define CF_USE_INLINE_SAVE
38#undef CF_USE_INLINE
39#endif
40#include "cf_iter.h"
41#ifdef CF_USE_INLINE_SAVE
42#define CF_USE_INLINE
43#undef CF_USE_INLINE_SAVE
44#endif
45#endif /* ! INCL_CF_ITER_INLINE_CC */
46
47// more regular include files
48#include "int_cf.h"
49#include "int_poly.h"
50
51// set the value of `CF_INLINE' for the following methods and
52// functions
53#if defined( CF_USE_INLINE ) && defined( INCL_CF_ITER_INLINE_CC )
54#undef CF_INLINE
55#define CF_INLINE inline
56#else
57#undef CF_INLINE
58#define CF_INLINE
59#endif /* ! defined( CF_USE_INLINE ) && defined( INCL_CF_ITER_INLINE_CC ) */
60
61#ifndef INCL_CF_ITER_INLINE_CC
62// selectors
63//{{{ CF_INLINE int CFIterator::hasTerms () const
64//{{{ docu
65//
66// hasTerm() - check whether CO points to a valid term.
67//
68// Return true if CO points to a valid term, false if CO points
69// to the end of the sequence of terms.
70//
71//}}}
72CF_INLINE int
73CFIterator::hasTerms () const
74{
75    return hasterms;
76}
77//}}}
78
79//{{{ CF_INLINE CanonicalForm CFIterator::coeff () const
80//{{{ docu
81//
82// coeff() - return coefficient of current term of CO.
83//
84// CO has to point to a valid term.
85//
86//}}}
87CF_INLINE CanonicalForm
88CFIterator::coeff () const
89{
90    ASSERT( hasterms, "lib error: iterator out of terms" );
91    if ( ispoly )
92        return cursor->coeff;
93    else
94        return data;
95}
96//}}}
97
98//{{{ CF_INLINE int CFIterator::exp () const
99//{{{ docu
100//
101// exp() - return exponent of current term of CO.
102//
103// CO has to point to a valid term.
104//
105//}}}
106CF_INLINE int
107CFIterator::exp () const
108{
109    ASSERT( hasterms, "lib error: iterator out of terms" );
110    if ( ispoly )
111        return cursor->exp;
112    else
113        return 0;
114}
115//}}}
116
117// implementor methods
118//{{{ CFIterator::operator ++ (), operator ++ ( int )
119//{{{ docu
120//
121// operator ++() - advance CO to next term.
122//
123// Advance current term to next term in the sequence of terms or
124// to end of sequence.  CO has to point to a valid term.
125//
126// The postfix and prefix operator are identical.
127//
128//}}}
129CF_INLINE CFIterator &
130CFIterator::operator ++ ()
131{
132    ASSERT( hasterms, "lib error: iterator out of terms" );
133    if ( ispoly ) {
134        cursor = cursor->next;
135        hasterms = cursor != 0;
136    } else
137        hasterms = false;
138
139    return *this;
140}
141
142CF_INLINE CFIterator &
143CFIterator::operator ++ ( int )
144{
145    ASSERT( hasterms, "lib error: iterator out of terms" );
146    if ( ispoly ) {
147        cursor = cursor->next;
148        hasterms = cursor != 0;
149    } else
150        hasterms = false;
151
152    return *this;
153}
154//}}}
155#endif
Note: See TracBrowser for help on using the repository browser.