LCOV - code coverage report
Current view: top level - src - EntitySequence.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 22 22 100.0 %
Date: 2020-12-16 07:07:30 Functions: 10 10 100.0 %
Branches: 1 2 50.0 %

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

Generated by: LCOV version 1.11