source: git/factory/cf_iter_inline.cc @ 16f511

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