From 690c3e7bc0dc8259ec285f7bdcdca95600a4ab06 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Thu, 14 Oct 2004 17:32:56 +0000 Subject: [PATCH] fixed new playlist format (w/ playlistElement's and audioClipId's) --- .../core/include/LiveSupport/Core/Playlist.h | 67 +++++++++--- .../LiveSupport/Core/PlaylistElement.h | 22 +++- .../LiveSupport/Core/StorageClientInterface.h | 15 ++- livesupport/modules/core/src/Playlist.cxx | 22 +++- livesupport/modules/core/src/PlaylistTest.cxx | 102 +++++++++++++----- livesupport/modules/core/src/PlaylistTest.h | 20 +++- .../modules/storage/etc/storageClient.xml | 19 +++- .../modules/storage/etc/testStorage.xml | 19 +++- .../modules/storage/src/TestStorageClient.h | 21 +++- .../products/scheduler/etc/Makefile.in | 6 +- .../products/scheduler/etc/playlist.xml | 20 +++- .../products/scheduler/etc/storageClient.xml | 19 +++- .../src/DisplayPlaylistMethodTest.cxx | 6 +- .../src/DisplayPlaylistsMethodTest.cxx | 4 +- .../src/DisplayScheduleMethodTest.cxx | 10 +- .../src/OpenPlaylistForEditingMethod.cxx | 5 +- .../src/OpenPlaylistForEditingMethodTest.cxx | 4 +- .../products/scheduler/src/XmlRpcTools.cxx | 51 ++++++++- .../products/scheduler/src/XmlRpcTools.h | 44 +++++++- .../scheduler/src/XmlRpcToolsTest.cxx | 30 ++++-- 20 files changed, 415 insertions(+), 91 deletions(-) diff --git a/livesupport/modules/core/include/LiveSupport/Core/Playlist.h b/livesupport/modules/core/include/LiveSupport/Core/Playlist.h index a9a29944b..4e9bec2f7 100644 --- a/livesupport/modules/core/include/LiveSupport/Core/Playlist.h +++ b/livesupport/modules/core/include/LiveSupport/Core/Playlist.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $ ------------------------------------------------------------------------------*/ @@ -71,7 +71,7 @@ using namespace boost::posix_time; * the playlist. * * @author $Author: fgerlits $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class Playlist : public Configurable { @@ -113,6 +113,17 @@ class Playlist : public Configurable */ Ptr::Ref elementList; + /** + * Add a new playlist element to the playlist. + * + * @param playlistElement the new playlist element to be added + * @exception std::invalid_argument if the playlist already contains + * a playlist element with the same relative offset + */ + void + addPlaylistElement(Ptr::Ref playlistElement) + throw (std::invalid_argument); + public: /** @@ -195,10 +206,32 @@ class Playlist : public Configurable return playlength; } + /** + * Test whether the playlist is locked for editing. + * + * @return true if playlist is locked, false if not + */ + bool + getIsLockedForEditing() throw () + { + return isLockedForEditing; + } + + /** + * Test whether the playlist is locked for playing. + * + * @return true if playlist is locked, false if not + */ + bool + getIsLockedForPlaying() throw () + { + return isLockedForPlaying; + } + /** * Lock or unlock the playlist for editing. * - * @return true if successfully obtained or releasedlock; + * @return true if successfully obtained or released lock; * false otherwise. */ bool @@ -208,25 +241,13 @@ class Playlist : public Configurable /** * Lock or unlock the playlist for playing. * - * @return true if successfully obtained or releasedlock; + * @return true if successfully obtained or released lock; * false otherwise. */ bool setLockedForPlaying(bool lockStatus) throw (); - /** - * Add a new playlist element to the playlist. - * - * @param playlistElement the new playlist element to be added - * @exception std::invalid_argument if the playlist already contains - * a playlist element with the same relative offset as the - * new playlist element - */ - void - addPlaylistElement(Ptr::Ref playlistElement) - throw (std::invalid_argument); - /** * The iterator type for this class. * @@ -252,6 +273,20 @@ class Playlist : public Configurable { return elementList->end(); } + + /** + * Add a new audio clip to the playlist. + * + * @param relativeOffset the start of the audio clip, relative + * to the start of the playlist + * @param audioClip the new audio clip to be added + * @exception std::invalid_argument if the playlist already contains + * an audio clip with the same relative offset + */ + void + addAudioClip(Ptr::Ref audioClipId, + Ptr::Ref relativeOffset) + throw (std::invalid_argument); }; diff --git a/livesupport/modules/core/include/LiveSupport/Core/PlaylistElement.h b/livesupport/modules/core/include/LiveSupport/Core/PlaylistElement.h index 21c312afc..cb6dc4c7f 100644 --- a/livesupport/modules/core/include/LiveSupport/Core/PlaylistElement.h +++ b/livesupport/modules/core/include/LiveSupport/Core/PlaylistElement.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/PlaylistElement.h,v $ ------------------------------------------------------------------------------*/ @@ -72,7 +72,7 @@ using namespace LiveSupport::Core; * An item in a playlist. * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ class PlaylistElement : public Configurable { @@ -127,6 +127,24 @@ class PlaylistElement : public Configurable this->audioClipId = audioClipId; } + /** + * Create a new playlist element, with a new UniqueId, + * to be added to a playlist. + * + * @param audioClipId the ID of the audio clip associated + * with the playlist element. + * @param relativeOffset the start time of this element, relative to + * the start of the playlist. + */ + PlaylistElement(Ptr::Ref relativeOffset, + Ptr::Ref audioClipId) + throw () + { + this->id = UniqueId::generateId(); + this->relativeOffset = relativeOffset; + this->audioClipId = audioClipId; + } + /** * A virtual destructor, as this class has virtual functions. */ diff --git a/livesupport/modules/core/include/LiveSupport/Core/StorageClientInterface.h b/livesupport/modules/core/include/LiveSupport/Core/StorageClientInterface.h index 8a81e08c4..031c4e2e4 100644 --- a/livesupport/modules/core/include/LiveSupport/Core/StorageClientInterface.h +++ b/livesupport/modules/core/include/LiveSupport/Core/StorageClientInterface.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Attic/StorageClientInterface.h,v $ ------------------------------------------------------------------------------*/ @@ -61,7 +61,7 @@ namespace Core { * An interface for storage clients. * * @author $Author: fgerlits $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class StorageClientInterface { @@ -120,6 +120,17 @@ class StorageClientInterface virtual Ptr::Ref createPlaylist() throw () = 0; + /** + * Tell if an audio clip with a given id exists. + * + * @param id the id of the audio clip to check for. + * @return true if an audio clip with the specified id exists, + * false otherwise. + */ + virtual const bool + existsAudioClip(Ptr::Ref id) const throw () + = 0; + }; diff --git a/livesupport/modules/core/src/Playlist.cxx b/livesupport/modules/core/src/Playlist.cxx index 831e59909..4fcee9f07 100644 --- a/livesupport/modules/core/src/Playlist.cxx +++ b/livesupport/modules/core/src/Playlist.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $ ------------------------------------------------------------------------------*/ @@ -145,6 +145,26 @@ Playlist::addPlaylistElement(Ptr::Ref playlistElement) } +/*------------------------------------------------------------------------------ + * Add a new audio clip to the playlist. + *----------------------------------------------------------------------------*/ +void +Playlist::addAudioClip(Ptr::Ref audioClipId, + Ptr::Ref relativeOffset) + throw (std::invalid_argument) +{ + if (elementList->find(*relativeOffset) != elementList->end()) { + std::string eMsg = "Two playlist elements at the same relative offset"; + throw std::invalid_argument(eMsg); + } + + Ptr::Ref playlistElement(new PlaylistElement( + relativeOffset, audioClipId)); + + (*elementList)[*relativeOffset] = playlistElement; +} + + /*------------------------------------------------------------------------------ * Lock or unlock the playlist for editing. *----------------------------------------------------------------------------*/ diff --git a/livesupport/modules/core/src/PlaylistTest.cxx b/livesupport/modules/core/src/PlaylistTest.cxx index 37aadaaa1..57dd4373d 100644 --- a/livesupport/modules/core/src/PlaylistTest.cxx +++ b/livesupport/modules/core/src/PlaylistTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -50,6 +50,7 @@ using namespace std; using namespace LiveSupport::Core; + /* =================================================== local data structures */ @@ -74,6 +75,26 @@ static const std::string configFileName = "etc/playlist.xml"; void PlaylistTest :: setUp(void) throw () { + playlist.reset(new Playlist); + try { + Ptr::Ref parser( + new xmlpp::DomParser(configFileName, true)); + const xmlpp::Document * document = parser->get_document(); + const xmlpp::Element * root = document->get_root_node(); + + playlist->configure(*root); + + CPPUNIT_ASSERT(playlist->getId()->getId() == 1); + Ptr::Ref duration + = playlist->getPlaylength(); + CPPUNIT_ASSERT(duration->hours() == 1); + CPPUNIT_ASSERT(duration->minutes() == 30); + CPPUNIT_ASSERT(duration->seconds() == 0); + } catch (std::invalid_argument &e) { + CPPUNIT_FAIL("semantic error in configuration file"); + } catch (xmlpp::exception &e) { + CPPUNIT_FAIL("error parsing configuration file"); + } } @@ -93,28 +114,25 @@ void PlaylistTest :: firstTest(void) throw (CPPUNIT_NS::Exception) { - try { - Ptr::Ref parser( - new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - Ptr::Ref playlist(new Playlist()); + Playlist::const_iterator it = playlist->begin(); + CPPUNIT_ASSERT(it != playlist->end()); + Ptr::Ref playlistElement = it->second; + CPPUNIT_ASSERT(playlistElement->getId()->getId() == 101); + Ptr::Ref relativeOffset + = playlistElement->getRelativeOffset(); + CPPUNIT_ASSERT(relativeOffset->total_seconds() == 0); + CPPUNIT_ASSERT(playlistElement->getAudioClipId()->getId() == 10001); -// cout << "\nconfig elott\n"; - playlist->configure(*root); -// cout << "config utan\n"; - - CPPUNIT_ASSERT(playlist->getId()->getId() == 1); - Ptr::Ref duration - = playlist->getPlaylength(); - CPPUNIT_ASSERT(duration->hours() == 1); - CPPUNIT_ASSERT(duration->minutes() == 30); - CPPUNIT_ASSERT(duration->seconds() == 0); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL("semantic error in configuration file"); - } catch (xmlpp::exception &e) { - CPPUNIT_FAIL("error parsing configuration file"); - } + ++it; + CPPUNIT_ASSERT(it != playlist->end()); + playlistElement = it->second; + CPPUNIT_ASSERT(playlistElement->getId()->getId() == 102); + relativeOffset = playlistElement->getRelativeOffset(); + CPPUNIT_ASSERT(relativeOffset->total_seconds() == 60 * 60); + CPPUNIT_ASSERT(playlistElement->getAudioClipId()->getId() == 10002); + + ++it; + CPPUNIT_ASSERT(it == playlist->end()); } @@ -125,8 +143,6 @@ void PlaylistTest :: lockTest(void) throw (CPPUNIT_NS::Exception) { - Ptr::Ref playlist(new Playlist()); - CPPUNIT_ASSERT(playlist->setLockedForEditing(true)); CPPUNIT_ASSERT(!playlist->setLockedForEditing(true)); CPPUNIT_ASSERT(playlist->setLockedForEditing(false)); @@ -141,3 +157,41 @@ PlaylistTest :: lockTest(void) CPPUNIT_ASSERT(playlist->setLockedForPlaying(false)); CPPUNIT_ASSERT(!playlist->setLockedForEditing(true)); } + + +/*------------------------------------------------------------------------------ + * Test to see if we can add a new audio clip + *----------------------------------------------------------------------------*/ +void +PlaylistTest :: addAudioClipTest(void) + throw (CPPUNIT_NS::Exception) +{ + Ptr::Ref audioClipId(new UniqueId(20001)); + Ptr::Ref relativeOffset(new time_duration(0,10,0,0)); + // hour, min, sec, frac_sec + try { + playlist->addAudioClip(audioClipId, relativeOffset); + } + catch (std::invalid_argument &e) { + string eMsg = "addAudioClip returned with error: "; + eMsg += e.what(); + CPPUNIT_FAIL(eMsg); + } + + Playlist::const_iterator it = playlist->begin(); + CPPUNIT_ASSERT(it != playlist->end()); + + ++it; + Ptr::Ref playlistElement = it->second; + CPPUNIT_ASSERT(playlistElement->getAudioClipId()->getId() == 20001); + + Ptr::Ref otherRelativeOffset + = playlistElement->getRelativeOffset(); + CPPUNIT_ASSERT(otherRelativeOffset->total_seconds() == 10*60); + + ++it; + CPPUNIT_ASSERT(it != playlist->end()); + + ++it; + CPPUNIT_ASSERT(it == playlist->end()); +} diff --git a/livesupport/modules/core/src/PlaylistTest.h b/livesupport/modules/core/src/PlaylistTest.h index f576ddfe2..84d591ee1 100644 --- a/livesupport/modules/core/src/PlaylistTest.h +++ b/livesupport/modules/core/src/PlaylistTest.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.h,v $ ------------------------------------------------------------------------------*/ @@ -58,7 +58,7 @@ namespace Core { * Unit test for the UploadPlaylistMetohd class. * * @author $Author: fgerlits $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @see Playlist */ class PlaylistTest : public CPPUNIT_NS::TestFixture @@ -66,8 +66,16 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST_SUITE(PlaylistTest); CPPUNIT_TEST(firstTest); CPPUNIT_TEST(lockTest); + CPPUNIT_TEST(addAudioClipTest); CPPUNIT_TEST_SUITE_END(); + private: + + /** + * A playlist to play with. + */ + Ptr::Ref playlist; + protected: /** @@ -86,6 +94,14 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture void lockTest(void) throw (CPPUNIT_NS::Exception); + /** + * Trying to add a new audio clip. + * + * @exception CPPUNIT_NS::Exception on test failures. + */ + void + addAudioClipTest(void) throw (CPPUNIT_NS::Exception); + public: diff --git a/livesupport/modules/storage/etc/storageClient.xml b/livesupport/modules/storage/etc/storageClient.xml index fa5b4a8f0..b17aa123f 100644 --- a/livesupport/modules/storage/etc/storageClient.xml +++ b/livesupport/modules/storage/etc/storageClient.xml @@ -5,12 +5,27 @@ - + + + + + + + + + ]> - + + + + + + + + diff --git a/livesupport/modules/storage/etc/testStorage.xml b/livesupport/modules/storage/etc/testStorage.xml index 4b7a4066c..a0ac06fc6 100644 --- a/livesupport/modules/storage/etc/testStorage.xml +++ b/livesupport/modules/storage/etc/testStorage.xml @@ -3,10 +3,25 @@ - + + + + + + + + + ]> - + + + + + + + + diff --git a/livesupport/modules/storage/src/TestStorageClient.h b/livesupport/modules/storage/src/TestStorageClient.h index 13a24f4b2..d179be546 100644 --- a/livesupport/modules/storage/src/TestStorageClient.h +++ b/livesupport/modules/storage/src/TestStorageClient.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.h,v $ ------------------------------------------------------------------------------*/ @@ -67,7 +67,7 @@ using namespace LiveSupport::Core; * A dummy storage client, only used for test purposes. * * @author $Author: fgerlits $ - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class TestStorageClient : virtual public Configurable, @@ -167,7 +167,7 @@ class TestStorageClient : * @return a vector containing the playlists. */ virtual Ptr::Ref> >::Ref - getAllPlaylists(void) const throw (); + getAllPlaylists(void) const throw (); /** @@ -178,6 +178,21 @@ class TestStorageClient : virtual Ptr::Ref createPlaylist() throw (); + /** + * Tell if an audio clip with a given id exists. + * + * @param id the id of the audio clip to check for. + * @return true if an audio clip with the specified id exists, + * false otherwise. + * Note: at this point, this function always returns 'true'. + */ + virtual const bool + existsAudioClip(Ptr::Ref id) const + throw () + { + return true; + } + }; diff --git a/livesupport/products/scheduler/etc/Makefile.in b/livesupport/products/scheduler/etc/Makefile.in index 165d43bb3..4f706e9f8 100644 --- a/livesupport/products/scheduler/etc/Makefile.in +++ b/livesupport/products/scheduler/etc/Makefile.in @@ -21,7 +21,7 @@ # # # Author : $Author: fgerlits $ -# Version : $Revision: 1.12 $ +# Version : $Revision: 1.13 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $ # # @configure_input@ @@ -122,7 +122,8 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \ ${TMP_DIR}/DeletePlaylistMethod.o \ ${TMP_DIR}/DisplayPlaylistsMethod.o \ ${TMP_DIR}/OpenPlaylistForEditingMethod.o \ - ${TMP_DIR}/CreatePlaylistMethod.o + ${TMP_DIR}/CreatePlaylistMethod.o \ + ${TMP_DIR}/AddAudioClipToPlaylistMethod.o SCHEDULER_EXE_OBJS = ${SCHEDULER_OBJS} \ ${TMP_DIR}/main.o @@ -148,6 +149,7 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \ ${TMP_DIR}/DisplayPlaylistsMethodTest.o \ ${TMP_DIR}/OpenPlaylistForEditingMethodTest.o \ ${TMP_DIR}/CreatePlaylistMethodTest.o \ + ${TMP_DIR}/AddAudioClipToPlaylistMethodTest.o \ ${TMP_DIR}/TestRunner.o TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} -lcppunit -ldl diff --git a/livesupport/products/scheduler/etc/playlist.xml b/livesupport/products/scheduler/etc/playlist.xml index 5dc2234ee..1756dfb49 100644 --- a/livesupport/products/scheduler/etc/playlist.xml +++ b/livesupport/products/scheduler/etc/playlist.xml @@ -1,8 +1,24 @@ + + + + + + + + + ]> - + + + + + + + + + diff --git a/livesupport/products/scheduler/etc/storageClient.xml b/livesupport/products/scheduler/etc/storageClient.xml index 15600dfed..8b7e72a2d 100644 --- a/livesupport/products/scheduler/etc/storageClient.xml +++ b/livesupport/products/scheduler/etc/storageClient.xml @@ -5,12 +5,27 @@ - + + + + + + + + + ]> - + + + + + + + + diff --git a/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx b/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx index 893f9e7cb..dbc0711ff 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx +++ b/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -149,7 +149,7 @@ DisplayPlaylistMethodTest :: firstTest(void) method->execute(rootParameter, result); CPPUNIT_ASSERT(((int) result["id"]) == 1); - CPPUNIT_ASSERT(((int) result["playlength"]) == (60 * 60)); + CPPUNIT_ASSERT(((int) result["playlength"]) == (90 * 60)); } diff --git a/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx b/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx index 15e5baa4f..9a3f3c645 100644 --- a/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx +++ b/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -149,5 +149,5 @@ DisplayPlaylistsMethodTest :: firstTest(void) playlist = result[0]; CPPUNIT_ASSERT(((int) playlist["id"]) == 1); - CPPUNIT_ASSERT(((int) playlist["playlength"]) == (60 * 60)); + CPPUNIT_ASSERT(((int) playlist["playlength"]) == (90 * 60)); } diff --git a/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx b/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx index be8ee91e4..cd4c31bb1 100644 --- a/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx +++ b/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayScheduleMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -280,7 +280,7 @@ DisplayScheduleMethodTest :: intervalTest(void) CPPUNIT_ASSERT(time.tm_mon == 7); CPPUNIT_ASSERT(time.tm_mday == 31); CPPUNIT_ASSERT(time.tm_hour == 11); - CPPUNIT_ASSERT(time.tm_min == 0); + CPPUNIT_ASSERT(time.tm_min == 30); CPPUNIT_ASSERT(time.tm_sec == 0); // check for the interval 2004-07-31 between 9 and 13 o'clock @@ -317,7 +317,7 @@ DisplayScheduleMethodTest :: intervalTest(void) CPPUNIT_ASSERT(time.tm_mon == 7); CPPUNIT_ASSERT(time.tm_mday == 31); CPPUNIT_ASSERT(time.tm_hour == 11); - CPPUNIT_ASSERT(time.tm_min == 0); + CPPUNIT_ASSERT(time.tm_min == 30); CPPUNIT_ASSERT(time.tm_sec == 0); CPPUNIT_ASSERT((int)(result[1]["playlistId"]) == 1); @@ -333,7 +333,7 @@ DisplayScheduleMethodTest :: intervalTest(void) CPPUNIT_ASSERT(time.tm_mon == 7); CPPUNIT_ASSERT(time.tm_mday == 31); CPPUNIT_ASSERT(time.tm_hour == 13); - CPPUNIT_ASSERT(time.tm_min == 0); + CPPUNIT_ASSERT(time.tm_min == 30); CPPUNIT_ASSERT(time.tm_sec == 0); // check for the interval 2004-07-31 between 8 and 9 o'clock diff --git a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx index 6f65f36a9..9dd585320 100644 --- a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx +++ b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx,v $ ------------------------------------------------------------------------------*/ @@ -68,7 +68,8 @@ using namespace LiveSupport::Scheduler; /*------------------------------------------------------------------------------ * The name of this XML-RPC method. *----------------------------------------------------------------------------*/ -const std::string OpenPlaylistForEditingMethod::methodName = "openPlaylistForEditing"; +const std::string OpenPlaylistForEditingMethod::methodName + = "openPlaylistForEditing"; /*------------------------------------------------------------------------------ * The ID of this method for error reporting purposes. diff --git a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx index 123da1485..1e8818f0a 100644 --- a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx +++ b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -149,7 +149,7 @@ OpenPlaylistForEditingMethodTest :: firstTest(void) method->execute(parameter, result); CPPUNIT_ASSERT((int) result["id"] == 1); - CPPUNIT_ASSERT((int) result["playlength"] == (60 * 60)); + CPPUNIT_ASSERT((int) result["playlength"] == (90 * 60)); parameter.clear(); result.clear(); diff --git a/livesupport/products/scheduler/src/XmlRpcTools.cxx b/livesupport/products/scheduler/src/XmlRpcTools.cxx index 78c955cef..b850b8fd5 100644 --- a/livesupport/products/scheduler/src/XmlRpcTools.cxx +++ b/livesupport/products/scheduler/src/XmlRpcTools.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.cxx,v $ ------------------------------------------------------------------------------*/ @@ -56,11 +56,20 @@ using namespace LiveSupport::Scheduler; /* =================================================== local data structures */ /*------------------------------------------------------------------------------ - * The name of the playlistId member in the XML-RPC parameter - * structure. + * The name of the playlist ID member in the XML-RPC parameter structure *----------------------------------------------------------------------------*/ const std::string XmlRpcTools::playlistIdName = "playlistId"; +/*------------------------------------------------------------------------------ + * The name of the audio clip ID member in the XML-RPC parameter structure + *----------------------------------------------------------------------------*/ +const std::string XmlRpcTools::audioClipIdName = "audioClipId"; + +/*------------------------------------------------------------------------------ + * The name of the relative offset member in the XML-RPC parameter structure + *----------------------------------------------------------------------------*/ +const std::string XmlRpcTools::relativeOffsetName = "relativeOffset"; + /* ================================================ local constants & macros */ @@ -71,7 +80,7 @@ const std::string XmlRpcTools::playlistIdName = "playlistId"; /* ============================================================= module code */ /*------------------------------------------------------------------------------ - * Extract the UniqueId from an XML-RPC function call parameter + * Extract the playlist ID from an XML-RPC function call parameter *----------------------------------------------------------------------------*/ Ptr::Ref XmlRpcTools :: extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue) @@ -86,6 +95,40 @@ XmlRpcTools :: extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue) } +/*------------------------------------------------------------------------------ + * Extract the audio clip ID from an XML-RPC function call parameter + *----------------------------------------------------------------------------*/ +Ptr::Ref +XmlRpcTools :: extractAudioClipId(XmlRpc::XmlRpcValue & xmlRpcValue) + throw (std::invalid_argument) +{ + if (!xmlRpcValue.hasMember(audioClipIdName)) { + throw std::invalid_argument("no audio clip id in parameter structure"); + } + + Ptr::Ref id(new UniqueId((int) xmlRpcValue[audioClipIdName])); + return id; +} + + +/*------------------------------------------------------------------------------ + * Extract the relative offset from an XML-RPC function call parameter + *----------------------------------------------------------------------------*/ +Ptr::Ref +XmlRpcTools :: extractRelativeOffset(XmlRpc::XmlRpcValue & xmlRpcValue) + throw (std::invalid_argument) +{ + if (!xmlRpcValue.hasMember(relativeOffsetName)) { + throw std::invalid_argument("no relative offset " + "in parameter structure"); + } + + Ptr::Ref relativeOffset(new time_duration(0,0, + (int) xmlRpcValue[relativeOffsetName], 0)); + return relativeOffset; +} + + /*------------------------------------------------------------------------------ * Convert a Playlist to an XmlRpcValue *----------------------------------------------------------------------------*/ diff --git a/livesupport/products/scheduler/src/XmlRpcTools.h b/livesupport/products/scheduler/src/XmlRpcTools.h index 02a12c64b..ad6adbe52 100644 --- a/livesupport/products/scheduler/src/XmlRpcTools.h +++ b/livesupport/products/scheduler/src/XmlRpcTools.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.h,v $ ------------------------------------------------------------------------------*/ @@ -68,7 +68,7 @@ using namespace LiveSupport::Core; * in the Scheduler. * * @author $Author: fgerlits $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ class XmlRpcTools { @@ -79,18 +79,54 @@ class XmlRpcTools */ static const std::string playlistIdName; + /** + * The name of the playlistId member in the XML-RPC parameter + * structure given as the input to an XmlRpcServerMethod. + */ + static const std::string audioClipIdName; + + /** + * The name of the playlistId member in the XML-RPC parameter + * structure given as the input to an XmlRpcServerMethod. + */ + static const std::string relativeOffsetName; + /** * Extract the playlist id from the XML-RPC parameters. * * @param xmlRpcValue the XML-RPC parameter to extract from. * @return a UniqueId that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no UniqueId - * in xmlRpcValue + * @exception std::invalid_argument if there was no playlistId + * member in xmlRpcValue */ static Ptr::Ref extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue) throw (std::invalid_argument); + /** + * Extract the audio clip id from the XML-RPC parameters. + * + * @param xmlRpcValue the XML-RPC parameter to extract from. + * @return a UniqueId that was found in the XML-RPC parameter. + * @exception std::invalid_argument if there was no audioClipId + * member in xmlRpcValue + */ + static Ptr::Ref + extractAudioClipId(XmlRpc::XmlRpcValue & xmlRpcValue) + throw (std::invalid_argument); + + /** + * Extract the relative offset from the XML-RPC parameters. + * + * @param xmlRpcValue the XML-RPC parameter to extract from. + * @return a time_duration that was found in the XML-RPC parameter. + * @exception std::invalid_argument if there was no relativeOffset + * member in xmlRpcValue + */ + static Ptr::Ref + extractRelativeOffset(XmlRpc::XmlRpcValue & xmlRpcValue) + throw (std::invalid_argument); + /** * Convert a Playlist to an XmlRpcValue * diff --git a/livesupport/products/scheduler/src/XmlRpcToolsTest.cxx b/livesupport/products/scheduler/src/XmlRpcToolsTest.cxx index 7565a4e49..7d58b539a 100644 --- a/livesupport/products/scheduler/src/XmlRpcToolsTest.cxx +++ b/livesupport/products/scheduler/src/XmlRpcToolsTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcToolsTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -136,26 +136,38 @@ XmlRpcToolsTest :: firstTest(void) CPPUNIT_ASSERT(((int) xmlRpcPlaylist["id"]) == 1); CPPUNIT_ASSERT(((int) xmlRpcPlaylist["playlength"]) == (90 * 60)); - XmlRpcValue xmlRpcPlaylistId; - Ptr::Ref playlistId; - int randomNumber = rand(); + XmlRpcValue xmlRpcPlaylistId; + Ptr::Ref playlistId; + Ptr::Ref audioClipId; + Ptr::Ref relativeOffset; - xmlRpcPlaylistId["playlistId"] = randomNumber; + int playlistIdNum = rand(); + int audioClipIdNum = rand(); + int relativeOffsetNum = rand(); - // run the unpacking method + xmlRpcPlaylistId["playlistId"] = playlistIdNum; + xmlRpcPlaylistId["audioClipId"] = audioClipIdNum; + xmlRpcPlaylistId["relativeOffset"] = relativeOffsetNum; + + // run the unpacking methods try { - playlistId = XmlRpcTools :: extractPlaylistId(xmlRpcPlaylistId); + playlistId = XmlRpcTools::extractPlaylistId(xmlRpcPlaylistId); + audioClipId = XmlRpcTools::extractAudioClipId(xmlRpcPlaylistId); + relativeOffset = XmlRpcTools::extractRelativeOffset(xmlRpcPlaylistId); } catch (std::invalid_argument &e) { CPPUNIT_FAIL(e.what()); } - CPPUNIT_ASSERT((int)(playlistId->getId()) == randomNumber); + CPPUNIT_ASSERT((int)(playlistId->getId()) == playlistIdNum); + CPPUNIT_ASSERT((int)(audioClipId->getId()) == audioClipIdNum); + CPPUNIT_ASSERT((int)(relativeOffset->total_seconds()) + == relativeOffsetNum); } /*------------------------------------------------------------------------------ - * Testint markError() + * Testing markError() *----------------------------------------------------------------------------*/ void XmlRpcToolsTest :: errorTest(void)