MOAB: Mesh Oriented datABase  (version 5.3.0)
EntitySequence.hpp
Go to the documentation of this file.
00001 #ifndef ENTITY_SEQUENCE_HPP
00002 #define ENTITY_SEQUENCE_HPP
00003 
00004 #include "moab/Types.hpp"
00005 #include "Internals.hpp"
00006 
00007 namespace moab
00008 {
00009 
00010 class SequenceData;
00011 
00012 class EntitySequence
00013 {
00014   private:
00015     EntityHandle startHandle, endHandle;
00016     SequenceData* sequenceData;
00017 
00018   protected:
00019     EntitySequence( EntityHandle h ) : startHandle( h ), endHandle( h ), sequenceData( NULL ) {}
00020 
00021     EntitySequence( EntitySequence& split_from, EntityHandle here )
00022         : startHandle( here ), endHandle( split_from.endHandle ), sequenceData( split_from.sequenceData )
00023     {
00024         split_from.endHandle = here - 1;
00025     }
00026 
00027     SequenceData* create_data_subset( EntityHandle start_handle, EntityHandle end_handle, int num_sequence_arrays,
00028                                       unsigned const* bytes_per_element ) const;
00029 
00030     ErrorCode prepend_entities( EntityID count );
00031     ErrorCode append_entities( EntityID count );
00032 
00033   public:
00034     EntitySequence( EntityHandle start, EntityID count, SequenceData* dat )
00035         : startHandle( start ), endHandle( start + count - 1 ), sequenceData( dat )
00036     {
00037     }
00038 
00039     virtual ~EntitySequence() {}
00040 
00041     EntityType type() const
00042     {
00043         return TYPE_FROM_HANDLE( start_handle() );
00044     }
00045 
00046     EntityHandle start_handle() const
00047     {
00048         return startHandle;
00049     }
00050 
00051     EntityHandle end_handle() const
00052     {
00053         return endHandle;
00054     }
00055 
00056     SequenceData* data() const
00057     {
00058         return sequenceData;
00059     }
00060 
00061     void data( SequenceData* ptr )
00062     {
00063         sequenceData = ptr;
00064     }
00065 
00066     EntityID size() const
00067     {
00068         return endHandle - startHandle + 1;
00069     }
00070 
00071     /**\brief True if SequenceData has no holes and is used only
00072      *        by this EntitySequence */
00073     bool using_entire_data() const;
00074 
00075     /**\brief Integer value used in finding appropriate SequenceData
00076      *
00077      * This value is matched to input values by TypeSequenceManager to
00078      * determine if an available, unused portino of a SequenceData can
00079      * be used for a specific entity allocation.  For example, it is
00080      * used to find a SequenceData with the appropriate number of vertices
00081      * per element when allocating elements.  The default value is zero.
00082      */
00083     virtual int values_per_entity() const;
00084 
00085     /**\brief Split this sequence into two consecutive sequences
00086      *
00087      * Split this sequence into two sequences.
00088      *\param here New sequences should be [start_handle(),here) & [here,end_handle()]
00089      *\return New sequence containing [here,end_handle()]
00090      */
00091     virtual EntitySequence* split( EntityHandle here ) = 0;
00092 
00093     /**\brief Merge this sequence with another
00094      *
00095      * Combine two adjacent sequences.  Sequence handle blocks must be
00096      * consective and sequences must share a common SequenceData.
00097      */
00098     virtual ErrorCode merge( EntitySequence& other );
00099 
00100     /**\brief Erase entities in range: (end_handle()-count, end_handle()] */
00101     virtual ErrorCode pop_back( EntityID count );
00102 
00103     /**\brief Erase entities in range: [start_handle(), start_handle()+count) */
00104     virtual ErrorCode pop_front( EntityID count );
00105 
00106     /**\brief Create a new SequenceData that is a copy of a subset of
00107      *         the one referenced by this sequence.
00108      *
00109      * Create a new SequenceData that is a copy of a subset of the
00110      * SequenceData referenced by this EntitySequence.  Do not make any
00111      * changes to this EntitySequence or the current SequenceData.
00112      */
00113     virtual SequenceData* create_data_subset( EntityHandle start_handle, EntityHandle end_handle ) const = 0;
00114 
00115     /**\brief Get memory characteristcs that are the same for all entities
00116      *
00117      * Get charactersitic constant memory use for all entities in sequence.
00118      *\param bytes_per_entity The total bytes consumed for each entity in
00119      *                        the underlying SequenceData.  It is assumed
00120      *                        that the same amount of memory is consumed
00121      *                        for unused portions of the SequenceData.
00122      *\param size_of_sequence The size of the leaf subclass of this class
00123      */
00124     virtual void get_const_memory_use( unsigned long& bytes_per_entity, unsigned long& size_of_sequence ) const = 0;
00125     /**\brief Get portion of memory use that varies per entity
00126      *
00127      *\return Any per-entity memory use not accounted for in the results
00128      *        of get_const_memory_use.
00129      */
00130     virtual unsigned long get_per_entity_memory_use( EntityHandle first, EntityHandle last ) const;
00131 };
00132 
00133 }  // namespace moab
00134 
00135 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines