Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
SBucketFactory Class Reference

sBucket Factory More...

#include <syzextra.h>

Public Types

typedef Base::value_type Bucket
 

Public Member Functions

 SBucketFactory (const ring r)
 
 ~SBucketFactory ()
 
Bucket getBucket (const ring r, const bool remove=true)
 
void putBucket (const Bucket &bt, const bool replace=false)
 

Private Types

typedef std::stack< sBucket_ptBase
 

Private Member Functions

 SBucketFactory ()
 
 SBucketFactory (const SBucketFactory &)
 
void operator= (const SBucketFactory &)
 

Static Private Member Functions

static ring _GetBucketRing (const Bucket &bt)
 get bucket ring More...
 
static bool _IsBucketEmpty (const Bucket &bt)
 
static Bucket _CreateBucket (const ring r)
 inital allocation for new buckets More...
 
static void _DestroyBucket (Bucket &bt)
 we only expect empty buckets to be left at the end for destructor bt will be set to NULL More...
 

Private Attributes

const ring m_ring
 For debugging: all buckets are over the same ring... right?! More...
 

Detailed Description

sBucket Factory

Cleate/store/reuse buckets

Definition at line 74 of file syzextra.h.

Member Typedef Documentation

typedef std::stack<sBucket_pt> SBucketFactory::Base
private

Definition at line 77 of file syzextra.h.

typedef Base::value_type SBucketFactory::Bucket

Definition at line 83 of file syzextra.h.

Constructor & Destructor Documentation

SBucketFactory::SBucketFactory ( const ring  r)
inline

Definition at line 85 of file syzextra.h.

87  : m_ring(r)
88 #endif
89  {
90  push ( _CreateBucket(r) ); // start with at least one sBucket...?
91  assume( top() != NULL );
92  };
#define assume(x)
Definition: mod2.h:405
static Bucket _CreateBucket(const ring r)
inital allocation for new buckets
#define NULL
Definition: omList.c:10
const ring m_ring
For debugging: all buckets are over the same ring... right?!
Definition: syzextra.h:160
BEGIN_NAMESPACE_SINGULARXX const ring r
Definition: syzextra.h:47
SBucketFactory::~SBucketFactory ( )
inline

Definition at line 94 of file syzextra.h.

95  {
96  while( !empty() )
97  {
98  _DestroyBucket( top() );
99  pop();
100  }
101  }
static void _DestroyBucket(Bucket &bt)
we only expect empty buckets to be left at the end for destructor bt will be set to NULL ...
Definition: syzextra.cc:101
SBucketFactory::SBucketFactory ( )
private
SBucketFactory::SBucketFactory ( const SBucketFactory )
private

Member Function Documentation

static Bucket SBucketFactory::_CreateBucket ( const ring  r)
staticprivate

inital allocation for new buckets

void SBucketFactory::_DestroyBucket ( SBucketFactory::Bucket bt)
staticprivate

we only expect empty buckets to be left at the end for destructor bt will be set to NULL

Definition at line 101 of file syzextra.cc.

102 {
103  if( bt != NULL )
104  {
105  assume( _IsBucketEmpty(bt) );
106  sBucketDestroy( &bt );
107  bt = NULL;
108  }
109 }
static bool _IsBucketEmpty(const Bucket &bt)
assume(R!=NULL)
void sBucketDestroy(sBucket_pt *bucket)
Definition: sbuckets.cc:132
#define NULL
Definition: omList.c:10
static ring SBucketFactory::_GetBucketRing ( const Bucket bt)
staticprivate

get bucket ring

static bool SBucketFactory::_IsBucketEmpty ( const Bucket bt)
staticprivate
Bucket SBucketFactory::getBucket ( const ring  r,
const bool  remove = true 
)
inline

Definition at line 103 of file syzextra.h.

104  {
105  assume( r == m_ring );
106 
107  Bucket bt = NULL;
108 
109  if( !empty() )
110  {
111  bt = top();
112 
113  if( remove )
114  pop();
115  }
116  else
117  {
118  bt = _CreateBucket(r);
119 
120  if( !remove )
121  {
122  push(bt);
123  assume( bt == top() );
124  }
125  }
126 
127  assume( bt != NULL );
128  assume( _IsBucketEmpty(bt) );
129  assume( r == _GetBucketRing(bt) );
130 
131  return bt;
132  }
static bool _IsBucketEmpty(const Bucket &bt)
static ring _GetBucketRing(const Bucket &bt)
get bucket ring
#define assume(x)
Definition: mod2.h:405
static Bucket _CreateBucket(const ring r)
inital allocation for new buckets
#define NULL
Definition: omList.c:10
Base::value_type Bucket
Definition: syzextra.h:83
const ring m_ring
For debugging: all buckets are over the same ring... right?!
Definition: syzextra.h:160
BEGIN_NAMESPACE_SINGULARXX const ring r
Definition: syzextra.h:47
void SBucketFactory::operator= ( const SBucketFactory )
private
void SBucketFactory::putBucket ( const Bucket bt,
const bool  replace = false 
)
inline

Definition at line 135 of file syzextra.h.

136  {
137  assume( bt != NULL );
138  assume( _IsBucketEmpty(bt) );
139  assume( m_ring == _GetBucketRing(bt) );
140 
141  if( empty() )
142  push( bt );
143  else
144  {
145  if( replace )
146  top() = bt;
147  else
148  {
149  if( bt != top() )
150  push( bt );
151  }
152  }
153 
154  assume( bt == top() );
155  }
static bool _IsBucketEmpty(const Bucket &bt)
static ring _GetBucketRing(const Bucket &bt)
get bucket ring
#define assume(x)
Definition: mod2.h:405
#define NULL
Definition: omList.c:10
const ring m_ring
For debugging: all buckets are over the same ring... right?!
Definition: syzextra.h:160

Field Documentation

const ring SBucketFactory::m_ring
private

For debugging: all buckets are over the same ring... right?!

Definition at line 160 of file syzextra.h.


The documentation for this class was generated from the following files: