Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
EntitySequence.hpp
Go to the documentation of this file.
1 #ifndef ENTITY_SEQUENCE_HPP
2 #define ENTITY_SEQUENCE_HPP
3 
4 #include "moab/Types.hpp"
5 #include "Internals.hpp"
6 
7 namespace moab
8 {
9 
10 class SequenceData;
11 
13 {
14  private:
17 
18  protected:
20 
22  : startHandle( here ), endHandle( split_from.endHandle ), sequenceData( split_from.sequenceData )
23  {
24  split_from.endHandle = here - 1;
25  }
26 
29  int num_sequence_arrays,
30  unsigned const* bytes_per_element ) const;
31 
34 
35  public:
37  : startHandle( start ), endHandle( start + count - 1 ), sequenceData( dat )
38  {
39  }
40 
41  virtual ~EntitySequence() {}
42 
43  EntityType type() const
44  {
45  return TYPE_FROM_HANDLE( start_handle() );
46  }
47 
49  {
50  return startHandle;
51  }
52 
54  {
55  return endHandle;
56  }
57 
58  SequenceData* data() const
59  {
60  return sequenceData;
61  }
62 
63  void data( SequenceData* ptr )
64  {
65  sequenceData = ptr;
66  }
67 
68  EntityID size() const
69  {
70  return endHandle - startHandle + 1;
71  }
72 
73  /**\brief True if SequenceData has no holes and is used only
74  * by this EntitySequence */
75  bool using_entire_data() const;
76 
77  /**\brief Integer value used in finding appropriate SequenceData
78  *
79  * This value is matched to input values by TypeSequenceManager to
80  * determine if an available, unused portino of a SequenceData can
81  * be used for a specific entity allocation. For example, it is
82  * used to find a SequenceData with the appropriate number of vertices
83  * per element when allocating elements. The default value is zero.
84  */
85  virtual int values_per_entity() const;
86 
87  /**\brief Split this sequence into two consecutive sequences
88  *
89  * Split this sequence into two sequences.
90  *\param here New sequences should be [start_handle(),here) & [here,end_handle()]
91  *\return New sequence containing [here,end_handle()]
92  */
93  virtual EntitySequence* split( EntityHandle here ) = 0;
94 
95  /**\brief Merge this sequence with another
96  *
97  * Combine two adjacent sequences. Sequence handle blocks must be
98  * consective and sequences must share a common SequenceData.
99  */
100  virtual ErrorCode merge( EntitySequence& other );
101 
102  /**\brief Erase entities in range: (end_handle()-count, end_handle()] */
103  virtual ErrorCode pop_back( EntityID count );
104 
105  /**\brief Erase entities in range: [start_handle(), start_handle()+count) */
106  virtual ErrorCode pop_front( EntityID count );
107 
108  /**\brief Create a new SequenceData that is a copy of a subset of
109  * the one referenced by this sequence.
110  *
111  * Create a new SequenceData that is a copy of a subset of the
112  * SequenceData referenced by this EntitySequence. Do not make any
113  * changes to this EntitySequence or the current SequenceData.
114  */
116 
117  /**\brief Get memory characteristcs that are the same for all entities
118  *
119  * Get charactersitic constant memory use for all entities in sequence.
120  *\param bytes_per_entity The total bytes consumed for each entity in
121  * the underlying SequenceData. It is assumed
122  * that the same amount of memory is consumed
123  * for unused portions of the SequenceData.
124  *\param size_of_sequence The size of the leaf subclass of this class
125  */
126  virtual void get_const_memory_use( unsigned long& bytes_per_entity, unsigned long& size_of_sequence ) const = 0;
127  /**\brief Get portion of memory use that varies per entity
128  *
129  *\return Any per-entity memory use not accounted for in the results
130  * of get_const_memory_use.
131  */
132  virtual unsigned long get_per_entity_memory_use( EntityHandle first, EntityHandle last ) const;
133 };
134 
135 } // namespace moab
136 
137 #endif