added locking to Playlist

made collaboration diagrams for createPlaylist and openPlaylistForEditing
This commit is contained in:
fgerlits 2004-10-07 19:35:41 +00:00
parent 39dd193d00
commit e21003f101
7 changed files with 138 additions and 19 deletions

View File

@ -13,8 +13,8 @@ project, Copyright &#169; 2004 <a href="http://www.mdlf.org/">Media
Development Loan Fund</a>, under the GNU <a Development Loan Fund</a>, under the GNU <a
href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br> href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br>
<ul> <ul>
<li>Author: $Author: maroy $</li> <li>Author: $Author: fgerlits $</li>
<li>Version: $Revision: 1.2 $</li> <li>Version: $Revision: 1.3 $</li>
<li>Location: $Source: <li>Location: $Source:
/home/cvs/livesupport/doc/model/Scheduler/index.html,v $</li> /home/cvs/livesupport/doc/model/Scheduler/index.html,v $</li>
</ul> </ul>
@ -2205,7 +2205,7 @@ for the specified playlistId, indicate as an error.<br>
<tr> <tr>
<td valign="top"><b>Name</b><br> <td valign="top"><b>Name</b><br>
</td> </td>
<td colspan="2" rowspan="1" valign="top">displayPlaylist<br> <td colspan="2" rowspan="1" valign="top">deletePlaylist<br>
(playlist : Playlist)<br> (playlist : Playlist)<br>
: void<br> : void<br>
</td> </td>
@ -2558,7 +2558,7 @@ in the Playlist store.<br>
<tr> <tr>
<td valign="top"><b>Name</b><br> <td valign="top"><b>Name</b><br>
</td> </td>
<td colspan="2" rowspan="1" valign="top">displayPlaylists<br> <td colspan="2" rowspan="1" valign="top">displayPlayLog<br>
()<br> ()<br>
: Play log<br> : Play log<br>
</td> </td>

View File

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.1 $ Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -68,8 +68,8 @@ using namespace boost::posix_time;
* information of when and how each audio clip is played inside * information of when and how each audio clip is played inside
* the playlist. * the playlist.
* *
* @author $Author: maroy $ * @author $Author: fgerlits $
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
class Playlist : public Configurable class Playlist : public Configurable
{ {
@ -89,6 +89,16 @@ class Playlist : public Configurable
*/ */
Ptr<time_duration>::Ref playlength; Ptr<time_duration>::Ref playlength;
/**
* Flag set if playlist is currently playing.
*/
bool isLockedForPlaying;
/**
* Flag set if playlist is currently being edited.
*/
bool isLockedForEditing;
public: public:
/** /**
@ -96,6 +106,8 @@ class Playlist : public Configurable
*/ */
Playlist(void) throw () Playlist(void) throw ()
{ {
this->isLockedForPlaying = false;
this->isLockedForEditing = false;
} }
/** /**
@ -110,6 +122,8 @@ class Playlist : public Configurable
{ {
this->id = id; this->id = id;
this->playlength = playlength; this->playlength = playlength;
this->isLockedForPlaying = false;
this->isLockedForEditing = false;
} }
/** /**
@ -169,6 +183,27 @@ class Playlist : public Configurable
{ {
return playlength; return playlength;
} }
/**
* Lock or unlock the playlist for editing.
*
* @return true if successfully obtained or releasedlock;
* false otherwise.
*/
bool
setLockedForEditing(bool lockStatus)
throw ();
/**
* Lock or unlock the playlist for playing.
*
* @return true if successfully obtained or releasedlock;
* false otherwise.
*/
bool
setLockedForPlaying(bool lockStatus)
throw ();
}; };

View File

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.1 $ Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -103,3 +103,54 @@ Playlist :: configure(const xmlpp::Element & element)
duration_from_string(attribute->get_value()))); duration_from_string(attribute->get_value())));
} }
/*------------------------------------------------------------------------------
* Lock or unlock the playlist for editing.
*----------------------------------------------------------------------------*/
bool
Playlist::setLockedForEditing(bool lockStatus)
throw ()
{
if (lockStatus == true) {
if (isLockedForPlaying || isLockedForEditing) {
return false;
}
else {
isLockedForEditing = true;
return true;
}
}
else {
if (isLockedForPlaying) {
return false;
}
else {
isLockedForEditing = false;
return true; // returns true also if playlist
} // was already unlocked!
}
}
/*------------------------------------------------------------------------------
* Lock or unlock the playlist for playing.
*----------------------------------------------------------------------------*/
bool
Playlist::setLockedForPlaying(bool lockStatus)
throw ()
{
if (lockStatus == true) {
if (isLockedForPlaying) {
return false;
}
else {
isLockedForPlaying = true; // preserve LockedForEditing state
return true;
}
}
else {
isLockedForPlaying = false; // restore LockedForEditing state;
return true; // returns true also if playlist
} // was already unlocked!
}

View File

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.1 $ Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -114,3 +114,27 @@ PlaylistTest :: firstTest(void)
} }
} }
/*------------------------------------------------------------------------------
* Test to see if locking works
*----------------------------------------------------------------------------*/
void
PlaylistTest :: lockTest(void)
throw (CPPUNIT_NS::Exception)
{
Ptr<Playlist>::Ref playlist(new Playlist());
CPPUNIT_ASSERT(playlist->setLockedForEditing(true));
CPPUNIT_ASSERT(!playlist->setLockedForEditing(true));
CPPUNIT_ASSERT(playlist->setLockedForEditing(false));
CPPUNIT_ASSERT(playlist->setLockedForPlaying(true));
CPPUNIT_ASSERT(!playlist->setLockedForPlaying(true));
CPPUNIT_ASSERT(playlist->setLockedForPlaying(false));
CPPUNIT_ASSERT(playlist->setLockedForEditing(true));
CPPUNIT_ASSERT(playlist->setLockedForPlaying(true));
CPPUNIT_ASSERT(!playlist->setLockedForEditing(false));
CPPUNIT_ASSERT(playlist->setLockedForPlaying(false));
CPPUNIT_ASSERT(!playlist->setLockedForEditing(true));
}

View File

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $ Author : $Author: fgerlits $
Version : $Revision: 1.1 $ Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -57,14 +57,15 @@ namespace Core {
/** /**
* Unit test for the UploadPlaylistMetohd class. * Unit test for the UploadPlaylistMetohd class.
* *
* @author $Author: maroy $ * @author $Author: fgerlits $
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
* @see Playlist * @see Playlist
*/ */
class PlaylistTest : public CPPUNIT_NS::TestFixture class PlaylistTest : public CPPUNIT_NS::TestFixture
{ {
CPPUNIT_TEST_SUITE(PlaylistTest); CPPUNIT_TEST_SUITE(PlaylistTest);
CPPUNIT_TEST(firstTest); CPPUNIT_TEST(firstTest);
CPPUNIT_TEST(lockTest);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
protected: protected:
@ -77,6 +78,15 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture
void void
firstTest(void) throw (CPPUNIT_NS::Exception); firstTest(void) throw (CPPUNIT_NS::Exception);
/**
* Testing the locks.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
lockTest(void) throw (CPPUNIT_NS::Exception);
public: public:
/** /**

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.1 $ Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/DisplayPlaylistsMethod.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -81,10 +81,9 @@ using namespace LiveSupport::Core;
* <li>playlength - int - the playlist length of the playlist, in seconds * <li>playlength - int - the playlist length of the playlist, in seconds
* </li> * </li>
* </ul> * </ul>
* In case of an error, a simple false value is returned.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
{ {