00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2010 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 int GetMinLength() const; 00065 int GetMaxLength() const; 00067 impl::SequenceListImplPtr& Impl() const; 00068 ConstSequenceList(const impl::SequenceListImplPtr& impl); 00069 protected: 00070 00071 void CheckValidity() const; 00072 mutable impl::SequenceListImplPtr impl_; 00073 }; 00074 00078 class DLLEXPORT_OST_SEQ SequenceList { 00079 public: 00080 00081 typedef impl::SequenceListIterator<SequenceHandle, 00082 impl::SequenceImplListIterator> Iterator; 00083 typedef Iterator iterator; 00084 SequenceList(); 00085 void AddSequence(const SequenceHandle& sequence); 00086 00087 bool SequencesHaveEqualLength() const; 00088 // \brief get number of sequences 00089 int GetCount() const; 00090 SequenceHandle operator[](int index) const; 00091 Iterator Begin() const; 00092 Iterator End() const; 00093 00097 SequenceList Take(int n) const; 00098 00100 SequenceList Slice(int first, int n) const; 00101 // for stl compat 00102 Iterator begin() const { return Begin(); } 00103 Iterator end() const { return End(); } 00104 00105 bool IsValid() const; 00106 00107 int GetMinLength() const; 00108 int GetMaxLength() const; 00109 00110 // \internal 00111 impl::SequenceListImplPtr& Impl() const; 00112 SequenceList(const impl::SequenceListImplPtr& impl); 00113 00114 operator ConstSequenceList() const; 00115 protected: 00116 void CheckValidity() const; 00117 00118 mutable impl::SequenceListImplPtr impl_; 00119 }; 00120 00121 SequenceList DLLEXPORT_OST_SEQ CreateSequenceList(); 00122 ConstSequenceList DLLEXPORT_OST_SEQ CreateConstSequenceList(); 00123 00125 void DLLEXPORT_OST_SEQ SequenceListToInfo(const ConstSequenceList& seq_list, 00126 info::InfoGroup& group); 00127 00129 SequenceList DLLEXPORT_OST_SEQ SequenceListFromInfo(info::InfoGroup& group); 00130 }} 00131 00132 #endif
1.5.8