/[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 1098 by schoenebeck, Thu Mar 15 00:32:06 2007 UTC
# Line 2744  namespace { Line 2744  namespace {
2744    
2745      /** @brief Update chunks with current group settings.      /** @brief Update chunks with current group settings.
2746       *       *
2747       * Apply current Group field values to the respective. You have to call       * Apply current Group field values to the respective chunks. You have
2748       * File::Save() to make changes persistent.       * to call File::Save() to make changes persistent.
2749         *
2750         * Usually there is absolutely no need to call this method explicitly.
2751         * It will be called automatically when File::Save() was called.
2752       */       */
2753      void Group::UpdateChunks() {      void Group::UpdateChunks() {
2754          // make sure <3gri> and <3gnl> list chunks exist          // make sure <3gri> and <3gnl> list chunks exist
# Line 2893  namespace { Line 2896  namespace {
2896          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");
2897          SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), (DLS::Sample*) pSample);          SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), (DLS::Sample*) pSample);
2898          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");
2899            if (SamplesIterator != pSamples->end() && *SamplesIterator == pSample) ++SamplesIterator; // avoid iterator invalidation
2900          pSamples->erase(iter);          pSamples->erase(iter);
2901          delete pSample;          delete pSample;
2902      }      }
# Line 3029  namespace { Line 3033  namespace {
3033       * have to call Save() to make this persistent to the file.       * have to call Save() to make this persistent to the file.
3034       *       *
3035       * @param pInstrument - instrument to delete       * @param pInstrument - instrument to delete
3036       * @throws gig::Excption if given instrument could not be found       * @throws gig::Exception if given instrument could not be found
3037       */       */
3038      void File::DeleteInstrument(Instrument* pInstrument) {      void File::DeleteInstrument(Instrument* pInstrument) {
3039          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 3111  namespace {
3111          return pGroup;          return pGroup;
3112      }      }
3113    
3114        /** @brief Delete a group and its samples.
3115         *
3116         * This will delete the given Group object and all the samples that
3117         * belong to this group from the gig file. You have to call Save() to
3118         * make this persistent to the file.
3119         *
3120         * @param pGroup - group to delete
3121         * @throws gig::Exception if given group could not be found
3122         */
3123      void File::DeleteGroup(Group* pGroup) {      void File::DeleteGroup(Group* pGroup) {
3124          if (!pGroups) LoadGroups();          if (!pGroups) LoadGroups();
3125          std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup);          std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup);
3126          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");
3127          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!");
3128            // delete all members of this group
3129            for (Sample* pSample = pGroup->GetFirstSample(); pSample; pSample = pGroup->GetNextSample()) {
3130                DeleteSample(pSample);
3131            }
3132            // now delete this group object
3133            pGroups->erase(iter);
3134            delete pGroup;
3135        }
3136    
3137        /** @brief Delete a group.
3138         *
3139         * This will delete the given Group object from the gig file. All the
3140         * samples that belong to this group will not be deleted, but instead
3141         * be moved to another group. You have to call Save() to make this
3142         * persistent to the file.
3143         *
3144         * @param pGroup - group to delete
3145         * @throws gig::Exception if given group could not be found
3146         */
3147        void File::DeleteGroupOnly(Group* pGroup) {
3148            if (!pGroups) LoadGroups();
3149            std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup);
3150            if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group");
3151            if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!");
3152          // move all members of this group to another group          // move all members of this group to another group
3153          pGroup->MoveAll();          pGroup->MoveAll();
3154          pGroups->erase(iter);          pGroups->erase(iter);
# Line 3142  namespace { Line 3179  namespace {
3179          }          }
3180      }      }
3181    
3182        /**
3183         * Apply all the gig file's current instruments, samples, groups and settings
3184         * to the respective RIFF chunks. You have to call Save() to make changes
3185         * persistent.
3186         *
3187         * Usually there is absolutely no need to call this method explicitly.
3188         * It will be called automatically when File::Save() was called.
3189         *
3190         * @throws Exception - on errors
3191         */
3192        void File::UpdateChunks() {
3193            // first update base class's chunks
3194            DLS::File::UpdateChunks();
3195    
3196            // update group's chunks
3197            if (pGroups) {
3198                std::list<Group*>::iterator iter = pGroups->begin();
3199                std::list<Group*>::iterator end  = pGroups->end();
3200                for (; iter != end; ++iter) {
3201                    (*iter)->UpdateChunks();
3202                }
3203            }
3204        }
3205    
3206    
3207    
3208  // *************** Exception ***************  // *************** Exception ***************

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

  ViewVC Help
Powered by ViewVC