feat: added DeleteMDObjectByID() to MXF header and footer classes
authorJohn Hurst <jhurst@cinecert.com>
Mon, 31 Jul 2023 14:59:31 +0000 (07:59 -0700)
committerJohn Hurst <jhurst@cinecert.com>
Mon, 31 Jul 2023 14:59:31 +0000 (07:59 -0700)
src/MXF.cpp
src/MXF.h

index c9617272fb12600923017fc17a6cfc8d1fd537af..ebb3013d930f78beaf5ab3522be06599d5abe07a 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2005-2021, John Hurst
+Copyright (c) 2005-2022, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -221,6 +221,22 @@ ASDCP::MXF::Partition::PacketList::GetMDObjectByID(const UUID& ObjectID, Interch
   return RESULT_OK;
 }
 
+//
+ASDCP::Result_t
+ASDCP::MXF::Partition::PacketList::DeleteMDObjectByID(const UUID& ObjectID)
+{
+  std::map<UUID, InterchangeObject*>::iterator mi = m_Map.find(ObjectID);
+  
+  if ( mi == m_Map.end() )
+    {
+       return RESULT_FAIL;
+    }
+
+  delete (*mi).second;
+  m_Map.erase(mi);
+  return RESULT_OK;
+}
+
 //
 ASDCP::Result_t
 ASDCP::MXF::Partition::PacketList::GetMDObjectByType(const byte_t* ObjectID, InterchangeObject** Object)
@@ -885,12 +901,20 @@ ASDCP::MXF::OP1aHeader::InitFromBuffer(const byte_t* p, ui32_t l)
   return result;
 }
 
+//
 ASDCP::Result_t
 ASDCP::MXF::OP1aHeader::GetMDObjectByID(const UUID& ObjectID, InterchangeObject** Object)
 {
   return m_PacketList->GetMDObjectByID(ObjectID, Object);
 }
 
+//
+ASDCP::Result_t
+ASDCP::MXF::OP1aHeader::DeleteMDObjectByID(const UUID& ObjectID)
+{
+  return m_PacketList->DeleteMDObjectByID(ObjectID);
+}
+
 //
 ASDCP::Result_t
 ASDCP::MXF::OP1aHeader::GetMDObjectByType(const byte_t* ObjectID, InterchangeObject** Object)
@@ -1225,12 +1249,20 @@ ASDCP::MXF::OPAtomIndexFooter::Dump(FILE* stream)
     (*i)->Dump(stream);
 }
 
+//
 ASDCP::Result_t
 ASDCP::MXF::OPAtomIndexFooter::GetMDObjectByID(const UUID& ObjectID, InterchangeObject** Object)
 {
   return m_PacketList->GetMDObjectByID(ObjectID, Object);
 }
 
+//
+ASDCP::Result_t
+ASDCP::MXF::OPAtomIndexFooter::DeleteMDObjectByID(const UUID& ObjectID)
+{
+  return m_PacketList->DeleteMDObjectByID(ObjectID);
+}
+
 //
 ASDCP::Result_t
 ASDCP::MXF::OPAtomIndexFooter::GetMDObjectByType(const byte_t* ObjectID, InterchangeObject** Object)
index d27bc474475dd6954bcc27f9b0e3bb9970def78d..8ce77e19a9e48dde269d170b2d0b5ea8a1397dc3 100755 (executable)
--- a/src/MXF.h
+++ b/src/MXF.h
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2005-2021, John Hurst
+Copyright (c) 2005-2022, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -130,6 +130,7 @@ namespace ASDCP
            ~PacketList();
            void AddPacket(InterchangeObject* ThePacket); // takes ownership
            Result_t GetMDObjectByID(const UUID& ObjectID, InterchangeObject** Object);
+           Result_t DeleteMDObjectByID(const UUID& ObjectID);
            Result_t GetMDObjectByType(const byte_t* ObjectID, InterchangeObject** Object);
            Result_t GetMDObjectsByType(const byte_t* ObjectID, std::list<InterchangeObject*>& ObjectList);
          };
@@ -449,6 +450,7 @@ namespace ASDCP
          virtual Result_t WriteToFile(Kumu::FileWriter& Writer, ui32_t HeaderLength = 16384);
          virtual void     Dump(FILE* = 0);
          virtual Result_t GetMDObjectByID(const UUID&, InterchangeObject** = 0);
+         virtual Result_t DeleteMDObjectByID(const UUID& ObjectID);
          virtual Result_t GetMDObjectByType(const byte_t*, InterchangeObject** = 0);
          virtual Result_t GetMDObjectsByType(const byte_t* ObjectID, std::list<InterchangeObject*>& ObjectList);
          Identification*  GetIdentification();
@@ -485,6 +487,7 @@ namespace ASDCP
          virtual void     Dump(FILE* = 0);
 
          virtual Result_t GetMDObjectByID(const UUID&, InterchangeObject** = 0);
+         virtual Result_t DeleteMDObjectByID(const UUID& ObjectID);
          virtual Result_t GetMDObjectByType(const byte_t*, InterchangeObject** = 0);
          virtual Result_t GetMDObjectsByType(const byte_t* ObjectID, std::list<InterchangeObject*>& ObjectList);