00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2011 by the OpenStructure authors 00005 // 00006 // This library is free software; you can redistribute it and/or modify it under 00007 // the terms of the GNU Lesser General Public License as published by the Free 00008 // Software Foundation; either version 3.0 of the License, or (at your option) 00009 // any later version. 00010 // This library is distributed in the hope that it will be useful, but WITHOUT 00011 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00013 // details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this library; if not, write to the Free Software Foundation, Inc., 00017 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 //------------------------------------------------------------------------------ 00019 #ifndef OST_SEQ_SEQUENCE_LIST_HH 00020 #define OST_SEQ_SEQUENCE_LIST_HH 00021 00022 #include <ost/seq/impl/sequence_list_impl_fw.hh> 00023 #include <ost/seq/impl/sequence_list_iterator.hh> 00024 #include <ost/seq/sequence_handle.hh> 00025 00026 namespace ost { namespace seq { 00027 00028 class SequenceList; 00029 00033 class DLLEXPORT_OST_SEQ ConstSequenceList { 00034 public: 00035 friend class SequenceList; 00036 typedef impl::SequenceListIterator<ConstSequenceHandle, 00037 impl::SequenceImplListIterator> Iterator; 00038 typedef Iterator iterator; 00039 ConstSequenceList(); 00040 00041 void AddSequence(const ConstSequenceHandle& sequence); 00042 00044 int GetCount() const; 00045 00046 ConstSequenceHandle operator[](int index) const; 00047 Iterator Begin() const; 00048 Iterator End() const; 00049 00050 // for stl compat 00051 Iterator begin() const { return Begin(); } 00052 Iterator end() const { return End(); } 00053 00054 bool SequencesHaveEqualLength() const; 00055 bool IsValid() const; 00056 00060 ConstSequenceList Take(int n) const; 00061 00063 ConstSequenceList Slice(int first, int n) const; 00064 00065 ConstSequenceHandle FindSequence(const String& name) const; 00066 int GetMinLength() const; 00067 int GetMaxLength() const; 00069 impl::SequenceListImplPtr& Impl() const; 00070 ConstSequenceList(const impl::SequenceListImplPtr& impl); 00071 protected: 00072 00073 void CheckValidity() const; 00074 mutable impl::SequenceListImplPtr impl_; 00075 }; 00076 00080 class DLLEXPORT_OST_SEQ SequenceList { 00081 public: 00082 00083 typedef impl::SequenceListIterator<SequenceHandle, 00084 impl::SequenceImplListIterator> Iterator; 00085 typedef Iterator iterator; 00086 SequenceList(); 00087 void AddSequence(const SequenceHandle& sequence); 00088 00089 bool SequencesHaveEqualLength() const; 00090 // \brief get number of sequences 00091 int GetCount() const; 00092 SequenceHandle operator[](int index) const; 00093 Iterator Begin() const; 00094 Iterator End() const; 00095 00099 SequenceList Take(int n) const; 00100 00102 SequenceList Slice(int first, int n) const; 00103 // for stl compat 00104 Iterator begin() const { return Begin(); } 00105 Iterator end() const { return End(); } 00106 00107 bool IsValid() const; 00108 00109 int GetMinLength() const; 00110 int GetMaxLength() const; 00111 00112 SequenceHandle FindSequence(const String& name) const; 00113 // \internal 00114 impl::SequenceListImplPtr& Impl() const; 00115 SequenceList(const impl::SequenceListImplPtr& impl); 00116 00117 operator ConstSequenceList() const; 00118 protected: 00119 void CheckValidity() const; 00120 00121 mutable impl::SequenceListImplPtr impl_; 00122 }; 00123 00124 SequenceList DLLEXPORT_OST_SEQ CreateSequenceList(); 00125 ConstSequenceList DLLEXPORT_OST_SEQ CreateConstSequenceList(); 00126 00127 #if(OST_INFO_ENABLED) 00129 void DLLEXPORT_OST_SEQ SequenceListToInfo(const ConstSequenceList& seq_list, 00130 info::InfoGroup& group); 00131 00133 SequenceList DLLEXPORT_OST_SEQ SequenceListFromInfo(info::InfoGroup& group); 00134 #endif 00135 }} 00136 00137 #endif