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

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

  ViewVC Help
Powered by ViewVC