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

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

  ViewVC Help
Powered by ViewVC