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