Skip to content

Commit

Permalink
Remove option to store archive test data to file because audio source…
Browse files Browse the repository at this point in the history
…/modification persistent IDs were not stored
  • Loading branch information
sgretscher committed Jun 13, 2024
1 parent 101bbe3 commit ad3049e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 49 deletions.
22 changes: 0 additions & 22 deletions ExamplesCommon/Archives/Archives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,3 @@ bool ArchiveBase::writeBytes (std::streamoff position, std::streamsize length, c
return false;
}
}

/*******************************************************************************/

FileArchive::FileArchive (std::string path, const std::string& documentArchiveID)
: ArchiveBase { _stream, documentArchiveID }
{
try
{
// create the file if not yet existing
_stream.open (path, std::ios::app | std::ios::binary);
_stream.close ();

// open the file for reading and writing
_stream.open (path.c_str (), std::ios::out | std::ios::in | std::ios::binary);
ARA_INTERNAL_ASSERT (_stream.good ());
}
catch (std::exception& e)
{
ARA_WARN ("%s", e.what ());
ARA_INTERNAL_ASSERT (false);
}
}
14 changes: 1 addition & 13 deletions ExamplesCommon/Archives/Archives.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ArchiveBase
/*******************************************************************************/

// In-memory archive, using the optional provided std::string as initial data.
// \todo With C++20 the interface could be much more like in the file case:
// \todo With C++20, this could be optimized:
// an external string would always be required and it would be directly used
// as backing for the stream, preventing all the current temporary copies.
class MemoryArchive : public ArchiveBase
Expand All @@ -66,15 +66,3 @@ class MemoryArchive : public ArchiveBase
private:
std::stringstream _stream;
};

/*******************************************************************************/

// File-based archive, using the file at the provided path as backing.
class FileArchive : public ArchiveBase
{
public:
FileArchive (std::string path, const std::string& documentArchiveID);

private:
std::fstream _stream;
};
14 changes: 0 additions & 14 deletions TestHost/TestCases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,20 +348,11 @@ void testModificationCloning (PlugInEntry* plugInEntry, const AudioFileList& aud
// Demonstrates how to store and restore plug-in document archives
void testArchiving (PlugInEntry* plugInEntry, const AudioFileList& audioFiles)
{
// By default, this code stores the plug-in archivesin memory -
// define ARA_TEST_ARCHIVE_FILENAME here to specify an archive file that should be stored on disk.
//#define ARA_TEST_ARCHIVE_FILENAME "TestARAPersistence.dat"

ARA_LOG_TEST_HOST_FUNC ("archiving");

bool supportsARA2Persistency { false }; // will be properly set after creating document controller

#if defined (ARA_TEST_ARCHIVE_FILENAME)
std::remove (ARA_TEST_ARCHIVE_FILENAME);
auto archive = new FileArchive { ARA_TEST_ARCHIVE_FILENAME, plugInEntry->getARAFactory ()->documentArchiveID };
#else
auto archive = new MemoryArchive { plugInEntry->getARAFactory ()->documentArchiveID };
#endif

// create and archive the document,
// caching the audio source / modification persistent IDs
Expand Down Expand Up @@ -482,11 +473,6 @@ void testArchiving (PlugInEntry* plugInEntry, const AudioFileList& audioFiles)
}

delete archive;
#if defined (ARA_TEST_ARCHIVE_FILENAME)
std::remove (ARA_TEST_ARCHIVE_FILENAME);

#undef ARA_TEST_ARCHIVE_FILENAME
#endif
}

/*******************************************************************************/
Expand Down

0 comments on commit ad3049e

Please sign in to comment.