/[svn]/libgig/trunk/src/gig.cpp
ViewVC logotype

Diff of /libgig/trunk/src/gig.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3929 by schoenebeck, Tue Jun 15 12:22:26 2021 UTC revision 3935 by schoenebeck, Thu Jun 17 10:09:42 2021 UTC
# Line 6122  namespace { Line 6122  namespace {
6122      }      }
6123    
6124      /**      /**
6125         * Returns Sample object at @a index of this sample group.
6126         *
6127         * @param index - position of sample in this sample group's sample list
6128         *                (0..n)
6129         * @returns sample object or NULL if index is out of bounds
6130         */
6131        Sample* Group::GetSample(size_t index) {
6132            if (pFile->pSamples && index >= pFile->pSamples->size()) return NULL;
6133            size_t indexInFile = 0;
6134            size_t indexInGroup = 0;
6135            for (Sample* pSample = pFile->GetSample(indexInFile); pSample;
6136                         pSample = pFile->GetSample(++indexInFile))
6137            {
6138                if (pSample->GetGroup() != this) continue;
6139                if (indexInGroup++ == index) return pSample;
6140            }
6141            return NULL;
6142        }
6143    
6144        /**
6145       * Returns the first Sample of this Group. You have to call this method       * Returns the first Sample of this Group. You have to call this method
6146       * once before you use GetNextSample().       * once before you use GetNextSample().
6147       *       *
# Line 6131  namespace { Line 6151  namespace {
6151       * @returns  pointer address to first Sample or NULL if there is none       * @returns  pointer address to first Sample or NULL if there is none
6152       *           applied to this Group       *           applied to this Group
6153       * @see      GetNextSample()       * @see      GetNextSample()
6154         * @deprecated  This method is not reentrant-safe, use GetSample()
6155         *              instead.
6156       */       */
6157      Sample* Group::GetFirstSample() {      Sample* Group::GetFirstSample() {
6158          size_t& i = this->SamplesIterator;          size_t& i = this->SamplesIterator;
# Line 6153  namespace { Line 6175  namespace {
6175       * @returns  pointer address to the next Sample of this Group or NULL if       * @returns  pointer address to the next Sample of this Group or NULL if
6176       *           end reached       *           end reached
6177       * @see      GetFirstSample()       * @see      GetFirstSample()
6178         * @deprecated  This method is not reentrant-safe, use GetSample()
6179         *              instead.
6180       */       */
6181      Sample* Group::GetNextSample() {      Sample* Group::GetNextSample() {
6182          size_t& i = this->SamplesIterator;          size_t& i = this->SamplesIterator;
# Line 6189  namespace { Line 6213  namespace {
6213              "other Group. This is a bug, report it!"              "other Group. This is a bug, report it!"
6214          );          );
6215          // now move all samples of this group to the other group          // now move all samples of this group to the other group
6216          for (Sample* pSample = GetFirstSample(); pSample; pSample = GetNextSample()) {          Sample* pSample;
6217            while ((pSample = GetSample(0))) {
6218              pOtherGroup->AddSample(pSample);              pOtherGroup->AddSample(pSample);
6219          }          }
6220      }      }
# Line 6931  namespace { Line 6956  namespace {
6956       * @param index - number of the sought group (0..n)       * @param index - number of the sought group (0..n)
6957       * @returns sought group or NULL if there's no such group       * @returns sought group or NULL if there's no such group
6958       */       */
6959      Group* File::GetGroup(uint index) {      Group* File::GetGroup(size_t index) {
6960          if (!pGroups) LoadGroups();          if (!pGroups) LoadGroups();
6961          GroupsIterator = pGroups->begin();          GroupsIterator = pGroups->begin();
6962          for (uint i = 0; GroupsIterator != pGroups->end(); i++) {          for (size_t i = 0; GroupsIterator != pGroups->end(); i++) {
6963              if (i == index) return *GroupsIterator;              if (i == index) return *GroupsIterator;
6964              ++GroupsIterator;              ++GroupsIterator;
6965          }          }
# Line 6983  namespace { Line 7008  namespace {
7008          if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group");          if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group");
7009          if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!");          if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!");
7010          // delete all members of this group          // delete all members of this group
7011          for (Sample* pSample = pGroup->GetFirstSample(); pSample; pSample = pGroup->GetNextSample()) {          Sample* pSample;
7012            while ((pSample = pGroup->GetSample(0))) {
7013              DeleteSample(pSample);              DeleteSample(pSample);
7014          }          }
7015          // now delete this group object          // now delete this group object

Legend:
Removed from v.3929  
changed lines
  Added in v.3935

  ViewVC Help
Powered by ViewVC