/[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 1076 by persson, Tue Mar 6 18:33:30 2007 UTC revision 1083 by schoenebeck, Thu Mar 8 16:41:27 2007 UTC
# Line 2893  namespace { Line 2893  namespace {
2893          if (!pSamples || !pSamples->size()) throw gig::Exception("Could not delete sample as there are no samples");          if (!pSamples || !pSamples->size()) throw gig::Exception("Could not delete sample as there are no samples");
2894          SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), (DLS::Sample*) pSample);          SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), (DLS::Sample*) pSample);
2895          if (iter == pSamples->end()) throw gig::Exception("Could not delete sample, could not find given sample");          if (iter == pSamples->end()) throw gig::Exception("Could not delete sample, could not find given sample");
2896            if (SamplesIterator != pSamples->end() && *SamplesIterator == pSample) ++SamplesIterator; // avoid iterator invalidation
2897          pSamples->erase(iter);          pSamples->erase(iter);
2898          delete pSample;          delete pSample;
2899      }      }
# Line 3029  namespace { Line 3030  namespace {
3030       * have to call Save() to make this persistent to the file.       * have to call Save() to make this persistent to the file.
3031       *       *
3032       * @param pInstrument - instrument to delete       * @param pInstrument - instrument to delete
3033       * @throws gig::Excption if given instrument could not be found       * @throws gig::Exception if given instrument could not be found
3034       */       */
3035      void File::DeleteInstrument(Instrument* pInstrument) {      void File::DeleteInstrument(Instrument* pInstrument) {
3036          if (!pInstruments) throw gig::Exception("Could not delete instrument as there are no instruments");          if (!pInstruments) throw gig::Exception("Could not delete instrument as there are no instruments");
# Line 3107  namespace { Line 3108  namespace {
3108          return pGroup;          return pGroup;
3109      }      }
3110    
3111        /** @brief Delete a group and its samples.
3112         *
3113         * This will delete the given Group object and all the samples that
3114         * belong to this group from the gig file. You have to call Save() to
3115         * make this persistent to the file.
3116         *
3117         * @param pGroup - group to delete
3118         * @throws gig::Exception if given group could not be found
3119         */
3120      void File::DeleteGroup(Group* pGroup) {      void File::DeleteGroup(Group* pGroup) {
3121          if (!pGroups) LoadGroups();          if (!pGroups) LoadGroups();
3122          std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup);          std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup);
3123          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");
3124            if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!");
3125            // delete all members of this group
3126            for (Sample* pSample = pGroup->GetFirstSample(); pSample; pSample = pGroup->GetNextSample()) {
3127                DeleteSample(pSample);
3128            }
3129            // now delete this group object
3130            pGroups->erase(iter);
3131            delete pGroup;
3132        }
3133    
3134        /** @brief Delete a group.
3135         *
3136         * This will delete the given Group object from the gig file. All the
3137         * samples that belong to this group will not be deleted, but instead
3138         * be moved to another group. You have to call Save() to make this
3139         * persistent to the file.
3140         *
3141         * @param pGroup - group to delete
3142         * @throws gig::Exception if given group could not be found
3143         */
3144        void File::DeleteGroupOnly(Group* pGroup) {
3145            if (!pGroups) LoadGroups();
3146            std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup);
3147            if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group");
3148          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!");
3149          // move all members of this group to another group          // move all members of this group to another group
3150          pGroup->MoveAll();          pGroup->MoveAll();

Legend:
Removed from v.1076  
changed lines
  Added in v.1083

  ViewVC Help
Powered by ViewVC