Commit d35a2ef7 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

browser on series now works

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1424
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 64333c11
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: README.changelog,v 1.39 2003-12-19 14:44:37 tforb Exp $
* $Id: README.changelog,v 1.40 2003-12-23 13:53:30 tforb Exp $
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
......@@ -21,12 +21,18 @@
/*! \page page_changelog ChangeLog (AFF)
$Id: README.changelog,v 1.39 2003-12-19 14:44:37 tforb Exp $
$Id: README.changelog,v 1.40 2003-12-23 13:53:30 tforb Exp $
\sa \ref page_project_status
Major changes in the interface of the library are marked by \b !!.
- \b 23/12/2003 (thof)
- defined Browser
- made Browser run with Series class (involves updates to SeriesStepper)
- created lib/linearshape.h to allow correct include order within
series.h
- \b 19/12/2003 (thof)
- TConstSharedHeap now allocates one element in the default constructor.
- \b !! cleaned all constructors of aff::ConstSeries and aff::Series
......@@ -178,7 +184,7 @@
/*! \page page_project_status Project status (AFF)
$Id: README.changelog,v 1.39 2003-12-19 14:44:37 tforb Exp $
$Id: README.changelog,v 1.40 2003-12-23 13:53:30 tforb Exp $
\sa \ref page_changelog
......@@ -258,6 +264,9 @@
<TR><TD>libaff/lib/iteratable.h</TD>
<TD> </TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/linearshape.h</TD>
<TD>23/12/2003</TD><TD> </TD><TD>23/12/2003 </TD><TD> </TD>
</TR>
<TR><TD>libaff/lib/range.h</TD>
<TD>13/12/02</TD><TD> </TD><TD> </TD><TD> </TD>
</TR>
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: iterator.h,v 1.7 2002-12-29 23:02:16 forbrig Exp $
* $Id: iterator.h,v 1.8 2003-12-23 13:53:30 tforb Exp $
* \author Thomas Forbriger
* \since 08/12/2002
*
......@@ -20,6 +20,11 @@
* - 28/12/2002 ---- (thof)
* - revised: is not affected by new style of base
* classes for constant elements
* - 23/12/2003 V1.2 (thof)
* - introduced Browser. Iterator may not be
* instantiated from a const object. It is not
* allowed to create a copy of SharedHeap from a
* const reference to a container.
*
* ============================================================================
*/
......@@ -28,15 +33,15 @@
#ifndef AFF_ITERATOR_H_VERSION
#define AFF_ITERATOR_H_VERSION \
"AFF_ITERATOR_H V1.1"
"AFF_ITERATOR_H V1.2"
#define AFF_ITERATOR_H_CVSID \
"$Id: iterator.h,v 1.7 2002-12-29 23:02:16 forbrig Exp $"
"$Id: iterator.h,v 1.8 2003-12-23 13:53:30 tforb Exp $"
#include<aff/lib/types.h>
namespace aff {
/*! \brief Iterator (and Browser)
/*! \brief Iterator
*
* \note
* This class holds an intrinsic reference to the Container components.
......@@ -102,6 +107,72 @@ namespace aff {
Trepresentation Mrepresentation;
}; // class Iterator
/*! \brief Browser
*
* \note
* This class holds an intrinsic reference to the Container components.
*
* \param C any container with appropriate interface (e.g. aff::Array,
* aff::Series)
*
* \todo
* Define requirements for the interface a container must provide.
*/
template<class C>
class Browser {
public:
//! type of container
typedef typename C::Tcontainer_of_const Tcontainer;
//! representation class
typedef typename Tcontainer::Trepresentation::Tcoc Trepresentation;
//! shape class
typedef typename Tcontainer::Tshape Tshape;
//! stepper base class
typedef typename Tcontainer::Tshape::Tstepper Tstepper;
//! value type
typedef typename Tcontainer::Tvalue Tvalue;
//! value type
typedef typename Tcontainer::Treference Treference;
//! value type
typedef typename Tcontainer::Tpointer Tpointer;
//! only this constructor
Browser(const C& c):
Mstepper(c.shape()), Mrepresentation(c.representation()) { }
//! delegate to stepper
//@{
bool more() const { return(Mstepper.more()); }
bool less() const { return(Mstepper.less()); }
bool valid() const { return(Mstepper.valid()); }
Browser& incr() { Mstepper.incr(); return(*this); }
Browser& decr() { Mstepper.decr(); return(*this); }
Browser& tofirst() { Mstepper.tofirst(); return(*this); }
Browser& tolast() { Mstepper.tolast(); return(*this); }
//@}
//! synonym for increment
Browser& operator++()
{ return(this->incr()); }
//! synonym for decrement
Browser& operator--()
{ return(this->decr()); }
//! access element
Treference operator*() const
{ return(Mrepresentation[Mstepper.current()]); }
//! member selection operator
Tpointer operator->() const
{ return(&(Mrepresentation[Mstepper.current()])); }
private:
//! Stepper to use
Tstepper Mstepper;
//! Representation to access
Trepresentation Mrepresentation;
}; // class Browser
} // namespace aff
#endif // AFF_ITERATOR_H_VERSION (includeguard)
......
/*! \file linearshape.h
* \brief Shape for Series class (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: linearshape.h,v 1.1 2003-12-23 13:53:31 tforb Exp $
* \author Thomas Forbriger
* \date 23/12/2003
*
* Shape for Series class (prototypes)
*
* Copyright (c) 2003 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 23/12/2003 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef AFF_LINEARSHAPE_H_VERSION
#define AFF_LINEARSHAPE_H_VERSION \
"AFF_LINEARSHAPE_H V1.0 "
#define AFF_LINEARSHAPE_H_CVSID \
"$Id: linearshape.h,v 1.1 2003-12-23 13:53:31 tforb Exp $"
namespace aff {
namespace util {
//! forward declaration of stepper class
class SeriesStepper;
} // namespace util
/*! \brief Shape for class aff::Series
*
* aff::Series needs its own shape class to provide an Array compatible
* interface to Iterator.
*
* The shape ist defined by three parameters, which are
* \a first, \a last, and \a base.
* The index \a k of the corresponding series must be in
* (\a first, \a last).
* While the range acessed within the representation is
* (\a first-base, \a last-base).
* Thus the element \a k of the series will be found at index \a k-base
* in the representation.
*/
class LinearShape
{
public:
typedef aff::util::SeriesStepper Tstepper;
LinearShape(): Mfirst(0), Mlast(0), Mbase(0) { }
LinearShape(const Tsubscript& first,
const Tsubscript& last,
const Tsubscript& firstinrepr):
Mfirst(first), Mlast(last), Mbase(first-firstinrepr)
{
AFF_assert((Mlast>Mfirst),
"ERROR (LinearShape): inconsistent constructor arguments");
}
const Tsubscript& first() const { return(Mfirst); }
const Tsubscript& last() const { return(Mlast); }
Tsubscript offset(const Tsubscript& i) const { return(i-Mbase); }
const Tsize& base() const { return(Mbase); }
//! by size we mean the size defined by the shape
Tsize size() const
{ return(static_cast<Tsize>(Mlast-Mfirst+1)); }
Tsize memory_size() const { return(this->size()); }
private:
Tsubscript Mfirst; //!< first valid index
Tsubscript Mlast; //!< last valid index
Tsize Mbase; //!< base for access to representation
}; // LinearShape
}
#endif // AFF_LINEARSHAPE_H_VERSION (includeguard)
/* ----- END OF linearshape.h ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: seriesstepper.h,v 1.2 2002-12-23 11:44:04 forbrig Exp $
* $Id: seriesstepper.h,v 1.3 2003-12-23 13:53:31 tforb Exp $
* \author Thomas Forbriger
* \date 20/12/2002
*
......@@ -18,6 +18,8 @@
* - 20/12/2002 V1.0 Thomas Forbriger
* - 23/12/2002 V1.1 (thof)
* - this class had no public interface
* - 23/12/2003 V1.2 (thof)
* - constructor must take shape as argument
*
* ============================================================================
*/
......@@ -26,9 +28,9 @@
#ifndef AFF_SERIESSTEPPER_H_VERSION
#define AFF_SERIESSTEPPER_H_VERSION \
"AFF_SERIESSTEPPER_H V1.1"
"AFF_SERIESSTEPPER_H V1.2"
#define AFF_SERIESSTEPPER_H_CVSID \
"$Id: seriesstepper.h,v 1.2 2002-12-23 11:44:04 forbrig Exp $"
"$Id: seriesstepper.h,v 1.3 2003-12-23 13:53:31 tforb Exp $"
#include<aff/lib/types.h>
......@@ -49,11 +51,11 @@ namespace util {
{
public:
//! only non-copy constructor
SeriesStepper(const Tsubscript& first,
const Tsubscript& last,
const Tsize& base):
Mfirst_offset(first-base), Mlast_offset(last-base),
Mbase(base), Mcurrent(first-base), Mvalid(true) { }
SeriesStepper(const LinearShape& shape):
Mfirst_offset(shape.offset(shape.first())),
Mlast_offset(shape.offset(shape.last())),
Mbase(shape.base()),
Mcurrent(Mfirst_offset), Mvalid(true) { }
//! return current index value for Representation access
const Tsubscript& current() const { return(Mcurrent); }
//! return current index vector for array access
......@@ -78,8 +80,8 @@ namespace util {
private:
//! store current bounds to reduce execution time
Tsubscript Mfirst_offset, Mlast_offset;
//! hold reference to shape
Tsize Mbase;
//! hold base to be able to return index value
Tsubscript Mbase;
//! hold current position offset to memory
Tsubscript Mcurrent;
//! true while not passed start or end
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: series.h,v 1.11 2003-12-19 14:38:15 tforb Exp $
* $Id: series.h,v 1.12 2003-12-23 13:53:30 tforb Exp $
* \author Thomas Forbriger
* \date 17/12/2002
*
......@@ -37,6 +37,11 @@
* - cleaning all constructors and parts of the
* documentation
* - some changes in LinearShape
* - 23/12/2003 V1.6 (thof)
* - return Trepresentation::Tcoc if requested
* - typedef Tstepper is not needed, is it?
* - well, it is needed. but you will find LinearShape
* in lib/linearshape.h now - anyway
*
* ============================================================================
*/
......@@ -45,60 +50,18 @@
#ifndef AFF_SERIES_H_VERSION
#define AFF_SERIES_H_VERSION \
"AFF_SERIES_H V1.5"
"AFF_SERIES_H V1.6"
#define AFF_SERIES_H_CVSID \
"$Id: series.h,v 1.11 2003-12-19 14:38:15 tforb Exp $"
"$Id: series.h,v 1.12 2003-12-23 13:53:30 tforb Exp $"
#include <aff/lib/sharedheap.h>
#include <aff/lib/linearshape.h>
#include <aff/lib/seriesstepper.h>
#include <aff/lib/error.h>
#include <aff/lib/deepcopy.h>
namespace aff {
/*! \brief Shape for class aff::Series
*
* aff::Series needs its own shape class to provide an Array compatible
* interface to Iterator.
*
* The shape ist defined by three parameters, which are
* \a first, \a last, and \a base.
* The index \a k of the corresponding series must be in
* (\a first, \a last).
* While the range acessed within the representation is
* (\a first-base, \a last-base).
* Thus the element \a k of the series will be found at index \a k-base
* in the representation.
*/
class LinearShape
{
public:
typedef aff::util::SeriesStepper Tstepper;
LinearShape(): Mfirst(0), Mlast(0), Mbase(0) { }
LinearShape(const Tsubscript& first,
const Tsubscript& last,
const Tsubscript& firstinrepr):
Mfirst(first), Mlast(last), Mbase(first-firstinrepr)
{
AFF_assert((Mlast>Mfirst),
"ERROR (LinearShape): inconsistent constructor arguments");
}
const Tsubscript& first() const { return(Mfirst); }
const Tsubscript& last() const { return(Mlast); }
Tsubscript offset(const Tsubscript& i) const { return(i-Mbase); }
const Tsize& base() const { return(Mbase); }
//! by size we mean the size defined by the shape
Tsize size() const
{ return(static_cast<Tsize>(Mlast-Mfirst+1)); }
Tsize memory_size() const { return(this->size()); }
private:
Tsubscript Mfirst; //!< first valid index
Tsubscript Mlast; //!< last valid index
Tsize Mbase; //!< base for access to representation
}; // LinearShape
/*======================================================================*/
/*! \brief base class
*
* \sa \ref sec_design_interface
......@@ -360,6 +323,10 @@ namespace aff {
const Trepresentation& representation()
{ return (Mrepresentation); }
//! expose representation
const typename Trepresentation::Tcoc& representation() const
{ return (Mrepresentation); }
private:
//! my (mutable) memory representation
Trepresentation Mrepresentation;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment