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
href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br>
<ul>
<li>Author: $Author: maroy $</li>
<li>Version: $Revision: 1.2 $</li>
<li>Author: $Author: fgerlits $</li>
<li>Version: $Revision: 1.3 $</li>
<li>Location: $Source:
/home/cvs/livesupport/doc/model/Scheduler/index.html,v $</li>
</ul>
@ -2205,7 +2205,7 @@ for the specified playlistId, indicate as an error.<br>
<tr>
<td valign="top"><b>Name</b><br>
</td>
<td colspan="2" rowspan="1" valign="top">displayPlaylist<br>
<td colspan="2" rowspan="1" valign="top">deletePlaylist<br>
(playlist : Playlist)<br>
: void<br>
</td>
@ -2558,7 +2558,7 @@ in the Playlist store.<br>
<tr>
<td valign="top"><b>Name</b><br>
</td>
<td colspan="2" rowspan="1" valign="top">displayPlaylists<br>
<td colspan="2" rowspan="1" valign="top">displayPlayLog<br>
()<br>
: Play log<br>
</td>

View File

@ -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/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
* the playlist.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
*/
class Playlist : public Configurable
{
@ -89,6 +89,16 @@ class Playlist : public Configurable
*/
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:
/**
@ -96,6 +106,8 @@ class Playlist : public Configurable
*/
Playlist(void) throw ()
{
this->isLockedForPlaying = false;
this->isLockedForEditing = false;
}
/**
@ -110,6 +122,8 @@ class Playlist : public Configurable
{
this->id = id;
this->playlength = playlength;
this->isLockedForPlaying = false;
this->isLockedForEditing = false;
}
/**
@ -169,6 +183,27 @@ class Playlist : public Configurable
{
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
Author : $Author: maroy $
Version : $Revision: 1.1 $
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
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())));
}
/*------------------------------------------------------------------------------
* 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
Author : $Author: maroy $
Version : $Revision: 1.1 $
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
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
Author : $Author: maroy $
Version : $Revision: 1.1 $
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
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.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @see Playlist
*/
class PlaylistTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE(PlaylistTest);
CPPUNIT_TEST(firstTest);
CPPUNIT_TEST(lockTest);
CPPUNIT_TEST_SUITE_END();
protected:
@ -77,6 +78,15 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture
void
firstTest(void) throw (CPPUNIT_NS::Exception);
/**
* Testing the locks.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
lockTest(void) throw (CPPUNIT_NS::Exception);
public:
/**

View File

@ -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/DisplayPlaylistsMethod.h,v $
------------------------------------------------------------------------------*/
@ -81,10 +81,9 @@ using namespace LiveSupport::Core;
* <li>playlength - int - the playlist length of the playlist, in seconds
* </li>
* </ul>
* In case of an error, a simple false value is returned.
*
* @author $Author: fgerlits $
* @version $Revision: 1.1 $
* @version $Revision: 1.2 $
*/
class DisplayPlaylistsMethod : public XmlRpc::XmlRpcServerMethod
{