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

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

  ViewVC Help
Powered by ViewVC