~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/lib/std/shl/obj/Cilo.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2011-03-16 21:31:18 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110316213118-gk4k3ez3e5d2huna
Tags: 2.0.0-1
* QA upload.
* New upstream release
* Debian source format is 3.0 (quilt)
* Fix debhelper-but-no-misc-depends
* Fix ancient-standards-version
* Fix package-contains-linda-override
* debhelper compatibility is 7
* Fix dh-clean-k-is-deprecated

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ---------------------------------------------------------------------------
2
 
// - Cilo.hpp                                                                -
3
 
// - standard object library - circular cilo class definition                -
4
 
// ---------------------------------------------------------------------------
5
 
// - This program is free software;  you can redistribute it  and/or  modify -
6
 
// - it provided that this copyright notice is kept intact.                  -
7
 
// -                                                                         -
8
 
// - This program  is  distributed in  the hope  that it will be useful, but -
9
 
// - without  any  warranty;  without  even   the   implied    warranty   of -
10
 
// - merchantability or fitness for a particular purpose.  In no event shall -
11
 
// - the copyright holder be liable for any  direct, indirect, incidental or -
12
 
// - special damages arising in any way out of the use of this software.     -
13
 
// ---------------------------------------------------------------------------
14
 
// - copyright (c) 1999-2007 amaury darsch                                   -
15
 
// ---------------------------------------------------------------------------
16
 
 
17
 
#ifndef  AFNIX_CILO_HPP
18
 
#define  AFNIX_CILO_HPP
19
 
 
20
 
#ifndef  AFNIX_STRING_HPP
21
 
#include "String.hpp"
22
 
#endif
23
 
 
24
 
namespace afnix {
25
 
 
26
 
  /// The Cilo class is a circular object container. By default, a cilo
27
 
  /// for 64 objects is created. The constructor also accepts an integer
28
 
  /// to preset size. Objects can be inserted with the 'add' method. When the
29
 
  /// cilo is full, the first object is overwritten. An index can be used to 
30
 
  /// traverse and reterive an object at a given position.
31
 
  /// @author amaury darsch
32
 
 
33
 
  class Cilo : public virtual Object {
34
 
  private:
35
 
    /// the cilo size
36
 
    long d_size;
37
 
    /// the start index
38
 
    long d_sidx;
39
 
    /// the end index
40
 
    long d_eidx;
41
 
    /// the traverse index
42
 
    long d_tidx;
43
 
    /// the full flag
44
 
    bool d_full;
45
 
    /// the allocated array
46
 
    Object** p_cilo;
47
 
 
48
 
  public:
49
 
    /// create a default cilo
50
 
    Cilo (void);
51
 
 
52
 
    /// create a cilo with a predefined allocated size
53
 
    /// @param size the requested size
54
 
    Cilo (const long size);
55
 
 
56
 
    /// copy constructor for this cilo
57
 
    /// @param that the cilo to copy 
58
 
    Cilo (const Cilo& that);
59
 
 
60
 
    /// destroy this cilo
61
 
    ~Cilo (void);
62
 
 
63
 
    /// @return the class name
64
 
    String repr (void) const;
65
 
 
66
 
    /// add an object to this cilo
67
 
    /// @param push the object to push
68
 
    void add (Object* object);
69
 
 
70
 
    /// @return true if the traverse object is at the top
71
 
    bool istop (void) const;
72
 
 
73
 
    /// @return true if the traverse object is at the bottom
74
 
    bool isbottom (void) const;
75
 
 
76
 
    /// @return the object by traversing upward
77
 
    Object* getup (void);
78
 
 
79
 
    /// @return the object by traversing downward
80
 
    Object* getdown (void);
81
 
 
82
 
  private:
83
 
    // make the assignment operator private
84
 
    Cilo& operator = (const Cilo&);
85
 
  };
86
 
}
87
 
 
88
 
#endif