/[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 3934 by schoenebeck, Thu Jun 17 09:44:03 2021 UTC revision 3941 by schoenebeck, Fri Jun 18 14:06:20 2021 UTC
# Line 609  namespace { Line 609  namespace {
609          uint16_t iSampleGroup = 0; // 0 refers to default sample group          uint16_t iSampleGroup = 0; // 0 refers to default sample group
610          File* pFile = static_cast<File*>(pParent);          File* pFile = static_cast<File*>(pParent);
611          if (pFile->pGroups) {          if (pFile->pGroups) {
612              std::list<Group*>::iterator iter = pFile->pGroups->begin();              std::vector<Group*>::iterator iter = pFile->pGroups->begin();
613              std::list<Group*>::iterator end  = pFile->pGroups->end();              std::vector<Group*>::iterator end  = pFile->pGroups->end();
614              for (int i = 0; iter != end; i++, iter++) {              for (int i = 0; iter != end; i++, iter++) {
615                  if (*iter == pGroup) {                  if (*iter == pGroup) {
616                      iSampleGroup = i;                      iSampleGroup = i;
# Line 5394  namespace { Line 5394  namespace {
5394       * @param dst - destination instrument at which this instrument will be       * @param dst - destination instrument at which this instrument will be
5395       *              moved to, or pass NULL for moving to end of list       *              moved to, or pass NULL for moving to end of list
5396       * @throw gig::Exception if this instrument and target instrument are not       * @throw gig::Exception if this instrument and target instrument are not
5397       *                       part of the same file       *                       part of the same file, as well as on unexpected
5398         *                       internal error
5399       */       */
5400      void Instrument::MoveTo(Instrument* dst) {      void Instrument::MoveTo(Instrument* dst) {
5401          if (dst && GetParent() != dst->GetParent())          if (dst && GetParent() != dst->GetParent())
# Line 5411  namespace { Line 5412  namespace {
5412    
5413              File::InstrumentList::iterator itFrom =              File::InstrumentList::iterator itFrom =
5414                  std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(this));                  std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(this));
5415                if (itFrom == list.end())
5416                    throw Exception(
5417                        "gig::Instrument::MoveTo(): unexpected missing membership "
5418                        "of this instrument."
5419                    );
5420                list.erase(itFrom);
5421    
5422              File::InstrumentList::iterator itTo =              File::InstrumentList::iterator itTo =
5423                  std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(dst));                  std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(dst));
5424    
5425              list.splice(itTo, list, itFrom);              list.insert(itTo, this);
5426          }          }
5427    
5428          // move the instrument's actual list RIFF chunk appropriately          // move the instrument's actual list RIFF chunk appropriately
# Line 6204  namespace { Line 6211  namespace {
6211       */       */
6212      void Group::MoveAll() {      void Group::MoveAll() {
6213          // get "that" other group first          // get "that" other group first
6214            size_t i = 0;
6215          Group* pOtherGroup = NULL;          Group* pOtherGroup = NULL;
6216          for (pOtherGroup = pFile->GetFirstGroup(); pOtherGroup; pOtherGroup = pFile->GetNextGroup()) {          for (pOtherGroup = pFile->GetGroup(i); pOtherGroup;
6217                 pOtherGroup = pFile->GetGroup(++i))
6218            {
6219              if (pOtherGroup != this) break;              if (pOtherGroup != this) break;
6220          }          }
6221          if (!pOtherGroup) throw Exception(          if (!pOtherGroup) throw Exception(
# Line 6286  namespace { Line 6296  namespace {
6296    
6297      File::~File() {      File::~File() {
6298          if (pGroups) {          if (pGroups) {
6299              std::list<Group*>::iterator iter = pGroups->begin();              std::vector<Group*>::iterator iter = pGroups->begin();
6300              std::list<Group*>::iterator end  = pGroups->end();              std::vector<Group*>::iterator end  = pGroups->end();
6301              while (iter != end) {              while (iter != end) {
6302                  delete *iter;                  delete *iter;
6303                  ++iter;                  ++iter;
# Line 6937  namespace { Line 6947  namespace {
6947          return bRequiresSave;          return bRequiresSave;
6948      }      }
6949    
6950        /**
6951         * Returns a pointer to the first <i>Group</i> object of the file,
6952         * <i>NULL</i> otherwise.
6953         *
6954         * @deprecated  This method is not reentrant-safe, use GetGroup() instead.
6955         */
6956      Group* File::GetFirstGroup() {      Group* File::GetFirstGroup() {
6957          if (!pGroups) LoadGroups();          if (!pGroups) LoadGroups();
6958          // there must always be at least one group          // there must always be at least one group
# Line 6944  namespace { Line 6960  namespace {
6960          return *GroupsIterator;          return *GroupsIterator;
6961      }      }
6962    
6963        /**
6964         * Returns a pointer to the next <i>Group</i> object of the file,
6965         * <i>NULL</i> otherwise.
6966         *
6967         * @deprecated  This method is not reentrant-safe, use GetGroup() instead.
6968         */
6969      Group* File::GetNextGroup() {      Group* File::GetNextGroup() {
6970          if (!pGroups) return NULL;          if (!pGroups) return NULL;
6971          ++GroupsIterator;          ++GroupsIterator;
# Line 6956  namespace { Line 6978  namespace {
6978       * @param index - number of the sought group (0..n)       * @param index - number of the sought group (0..n)
6979       * @returns sought group or NULL if there's no such group       * @returns sought group or NULL if there's no such group
6980       */       */
6981      Group* File::GetGroup(uint index) {      Group* File::GetGroup(size_t index) {
6982          if (!pGroups) LoadGroups();          if (!pGroups) LoadGroups();
6983          GroupsIterator = pGroups->begin();          if (index >= pGroups->size()) return NULL;
6984          for (uint i = 0; GroupsIterator != pGroups->end(); i++) {          return (*pGroups)[index];
             if (i == index) return *GroupsIterator;  
             ++GroupsIterator;  
         }  
         return NULL;  
6985      }      }
6986    
6987      /**      /**
# Line 6978  namespace { Line 6996  namespace {
6996       */       */
6997      Group* File::GetGroup(String name) {      Group* File::GetGroup(String name) {
6998          if (!pGroups) LoadGroups();          if (!pGroups) LoadGroups();
6999          GroupsIterator = pGroups->begin();          size_t i = 0;
7000          for (uint i = 0; GroupsIterator != pGroups->end(); ++GroupsIterator, ++i)          for (Group* pGroup = GetGroup(i); pGroup; pGroup = GetGroup(++i))
7001              if ((*GroupsIterator)->Name == name) return *GroupsIterator;              if (pGroup->Name == name) return pGroup;
7002          return NULL;          return NULL;
7003      }      }
7004    
# Line 7004  namespace { Line 7022  namespace {
7022       */       */
7023      void File::DeleteGroup(Group* pGroup) {      void File::DeleteGroup(Group* pGroup) {
7024          if (!pGroups) LoadGroups();          if (!pGroups) LoadGroups();
7025          std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup);          std::vector<Group*>::iterator iter =
7026                find(pGroups->begin(), pGroups->end(), pGroup);
7027          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");
7028          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!");
7029          // delete all members of this group          // delete all members of this group
# Line 7030  namespace { Line 7049  namespace {
7049       */       */
7050      void File::DeleteGroupOnly(Group* pGroup) {      void File::DeleteGroupOnly(Group* pGroup) {
7051          if (!pGroups) LoadGroups();          if (!pGroups) LoadGroups();
7052          std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup);          std::vector<Group*>::iterator iter =
7053                find(pGroups->begin(), pGroups->end(), pGroup);
7054          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");
7055          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!");
7056          // move all members of this group to another group          // move all members of this group to another group
# Line 7041  namespace { Line 7061  namespace {
7061      }      }
7062    
7063      void File::LoadGroups() {      void File::LoadGroups() {
7064          if (!pGroups) pGroups = new std::list<Group*>;          if (!pGroups) pGroups = new std::vector<Group*>;
7065          // try to read defined groups from file          // try to read defined groups from file
7066          RIFF::List* lst3gri = pRIFF->GetSubList(LIST_TYPE_3GRI);          RIFF::List* lst3gri = pRIFF->GetSubList(LIST_TYPE_3GRI);
7067          if (lst3gri) {          if (lst3gri) {
# Line 7240  namespace { Line 7260  namespace {
7260                  }                  }
7261              }              }
7262    
7263              std::list<Group*>::iterator iter = pGroups->begin();              std::vector<Group*>::iterator iter = pGroups->begin();
7264              std::list<Group*>::iterator end  = pGroups->end();              std::vector<Group*>::iterator end  = pGroups->end();
7265              for (; iter != end; ++iter) {              for (; iter != end; ++iter) {
7266                  (*iter)->UpdateChunks(pProgress);                  (*iter)->UpdateChunks(pProgress);
7267              }              }

Legend:
Removed from v.3934  
changed lines
  Added in v.3941

  ViewVC Help
Powered by ViewVC