MOAB: Mesh Oriented datABase  (version 5.2.1)
EntitySequence.cpp
Go to the documentation of this file.
00001 #include "EntitySequence.hpp"
00002 #include "SequenceData.hpp"
00003 
00004 namespace moab
00005 {
00006 
00007 bool EntitySequence::using_entire_data() const
00008 {
00009     return start_handle() == data()->start_handle() && end_handle() == data()->end_handle();
00010 }
00011 
00012 int EntitySequence::values_per_entity() const
00013 {
00014     return 0;
00015 }
00016 
00017 ErrorCode EntitySequence::pop_back( EntityID count )
00018 {
00019     EntityHandle new_end = endHandle - count;
00020     if( new_end < startHandle ) return MB_FAILURE;
00021 
00022     endHandle = new_end;
00023     return MB_SUCCESS;
00024 }
00025 
00026 ErrorCode EntitySequence::pop_front( EntityID count )
00027 {
00028     EntityHandle new_start = startHandle + count;
00029     if( new_start > endHandle ) return MB_FAILURE;
00030 
00031     startHandle = new_start;
00032     return MB_SUCCESS;
00033 }
00034 
00035 ErrorCode EntitySequence::prepend_entities( EntityID count )
00036 {
00037     EntityHandle new_start = startHandle - count;
00038     if( new_start < data()->start_handle() ) return MB_FAILURE;
00039 
00040     startHandle = new_start;
00041     return MB_SUCCESS;
00042 }
00043 
00044 ErrorCode EntitySequence::append_entities( EntityID count )
00045 {
00046     EntityHandle new_end = endHandle + count;
00047     if( new_end > data()->end_handle() ) return MB_FAILURE;
00048 
00049     endHandle = new_end;
00050     return MB_SUCCESS;
00051 }
00052 
00053 ErrorCode EntitySequence::merge( EntitySequence& other )
00054 {
00055     if( sequenceData != other.sequenceData ) return MB_FAILURE;
00056     if( end_handle() + 1 == other.start_handle() )
00057     {
00058         endHandle         = other.end_handle();
00059         other.startHandle = other.end_handle() + 1;
00060     }
00061     else if( start_handle() == other.end_handle() + 1 )
00062     {
00063         startHandle     = other.start_handle();
00064         other.endHandle = other.start_handle() - 1;
00065     }
00066     else
00067         return MB_FAILURE;
00068     return MB_SUCCESS;
00069 }
00070 
00071 unsigned long EntitySequence::get_per_entity_memory_use( EntityHandle, EntityHandle ) const
00072 {
00073     return 0;
00074 }
00075 
00076 }  // namespace moab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines