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