modified the play log methods
This commit is contained in:
parent
8e31c1e5b4
commit
b2e359ac21
Binary file not shown.
|
@ -1,119 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/PlayLogEntry.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "PlayLogEntry.h"
|
||||
|
||||
using namespace boost::posix_time;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the config element for this class
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string PlayLogEntry::configElementNameStr = "playLogEntry";
|
||||
|
||||
/**
|
||||
* The name of the attribute to get the id of the audio clip.
|
||||
*/
|
||||
static const std::string idAttrName = "id";
|
||||
|
||||
/**
|
||||
* The name of the attribute to get the ID of the audio clip logged.
|
||||
*/
|
||||
static const std::string audioClipIdAttrName = "audioClipId";
|
||||
|
||||
/**
|
||||
* The name of the attribute to get the time the audio clip was played.
|
||||
*/
|
||||
static const std::string timeStampAttrName = "timeStamp";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Create a play log entry object based on an XML element.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlayLogEntry :: configure(const xmlpp::Element & element)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (element.get_name() != configElementNameStr) {
|
||||
std::string eMsg = "bad configuration element ";
|
||||
eMsg += element.get_name();
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
|
||||
const xmlpp::Attribute * attribute;
|
||||
std::stringstream idStrStream;
|
||||
unsigned long int idValue;
|
||||
|
||||
if (!(attribute = element.get_attribute(idAttrName))) {
|
||||
std::string eMsg = "missing attribute ";
|
||||
eMsg += idAttrName;
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
idStrStream.str(attribute->get_value());
|
||||
idStrStream >> idValue;
|
||||
id.reset(new UniqueId(idValue));
|
||||
|
||||
std::stringstream audioClipIdStrStream;
|
||||
unsigned long int audioClipIdValue;
|
||||
|
||||
if (!(attribute = element.get_attribute(audioClipIdAttrName))) {
|
||||
std::string eMsg = "Missing attribute ";
|
||||
eMsg += audioClipIdAttrName;
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
audioClipIdStrStream.str(attribute->get_value());
|
||||
audioClipIdStrStream >> audioClipIdValue;
|
||||
audioClipId.reset(new UniqueId(audioClipIdValue));
|
||||
|
||||
if (!(attribute = element.get_attribute(timeStampAttrName))) {
|
||||
std::string eMsg = "missing attribute ";
|
||||
eMsg += timeStampAttrName;
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
timeStamp.reset(new ptime(time_from_string(attribute->get_value())));
|
||||
}
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/PlayLogEntry.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -47,7 +47,6 @@
|
|||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/UniqueId.h"
|
||||
#include "LiveSupport/Core/Configurable.h"
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
|
@ -69,7 +68,7 @@ using namespace LiveSupport::Core;
|
|||
* PlayLogEntries contain information about the audio clips played.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class PlayLogEntry
|
||||
{
|
||||
|
|
|
@ -1,124 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/PlayLogEntryTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Need unistd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "PlayLogEntry.h"
|
||||
#include "PlayLogEntryTest.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace boost::posix_time;
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::Scheduler;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(PlayLogEntryTest);
|
||||
|
||||
/**
|
||||
* The name of the configuration file for the audio clip.
|
||||
*/
|
||||
static const std::string configFileName = "etc/playLogEntry.xml";
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlayLogEntryTest :: setUp(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean up the test environment
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlayLogEntryTest :: tearDown(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test to see if the singleton Hello object is accessible
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
PlayLogEntryTest :: firstTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
try {
|
||||
Ptr<xmlpp::DomParser>::Ref parser(
|
||||
new xmlpp::DomParser(configFileName, true));
|
||||
const xmlpp::Document * document
|
||||
= parser->get_document();
|
||||
const xmlpp::Element * root
|
||||
= document->get_root_node();
|
||||
Ptr<PlayLogEntry>::Ref playLogEntry(new PlayLogEntry());
|
||||
|
||||
playLogEntry->configure(*root);
|
||||
|
||||
CPPUNIT_ASSERT(playLogEntry->getId()->getId() == 1);
|
||||
CPPUNIT_ASSERT(playLogEntry->getAudioClipId()->getId() == 10001);
|
||||
|
||||
Ptr<const ptime>::Ref
|
||||
timeStamp = playLogEntry->getTimeStamp();
|
||||
ptime beethovensBirthDay(time_from_string("1770-12-16 07:00:00"));
|
||||
CPPUNIT_ASSERT(*timeStamp == beethovensBirthDay);
|
||||
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL("semantic error in configuration file");
|
||||
} catch (xmlpp::exception &e) {
|
||||
std::string eMsg = "error parsing configuration file: ";
|
||||
eMsg += e.what();
|
||||
CPPUNIT_FAIL(eMsg);
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/PlayLogEntryTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef PlayLogEntryTest_h
|
||||
#define PlayLogEntryTest_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace Scheduler {
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* Unit test for the PlayLogEntry class.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see PlayLogEntry
|
||||
*/
|
||||
class PlayLogEntryTest : public CPPUNIT_NS::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(PlayLogEntryTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* A simple test.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Set up the environment for the test case.
|
||||
*/
|
||||
void
|
||||
setUp(void) throw ();
|
||||
|
||||
/**
|
||||
* Clean up the environment after the test case.
|
||||
*/
|
||||
void
|
||||
tearDown(void) throw ();
|
||||
};
|
||||
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace Scheduler
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // PlayLogEntryTest_h
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PlayLogInterface.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -70,7 +70,7 @@ using namespace LiveSupport::Core;
|
|||
* The generic interface for the component scheduling events.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class PlayLogInterface : virtual public Installable
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ class PlayLogInterface : virtual public Installable
|
|||
* @param timeStamp the time the clip was played (started).
|
||||
* @return the id of the newly created play log entry.
|
||||
*/
|
||||
virtual Ptr<const UniqueId>::Ref
|
||||
virtual Ptr<UniqueId>::Ref
|
||||
addPlayLogEntry(Ptr<const UniqueId>::Ref audioClipId,
|
||||
Ptr<const ptime>::Ref timeStamp)
|
||||
throw (std::invalid_argument)
|
||||
|
@ -97,7 +97,7 @@ class PlayLogInterface : virtual public Installable
|
|||
* non-inclusive
|
||||
* @return a vector of the play log entries for the time region.
|
||||
*/
|
||||
virtual Ptr<std::vector<Ptr<const PlayLogEntry>::Ref> >::Ref
|
||||
virtual Ptr<std::vector<Ptr<PlayLogEntry>::Ref> >::Ref
|
||||
getPlayLogEntries(Ptr<const ptime>::Ref fromTime,
|
||||
Ptr<const ptime>::Ref toTime)
|
||||
throw (std::invalid_argument)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlPlayLog.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -165,15 +165,15 @@ PostgresqlPlayLog :: uninstall(void) throw (std::exception)
|
|||
/*------------------------------------------------------------------------------
|
||||
* Add a new play log entry
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<const UniqueId>::Ref
|
||||
Ptr<UniqueId>::Ref
|
||||
PostgresqlPlayLog :: addPlayLogEntry(
|
||||
Ptr<const UniqueId>::Ref audioClipId,
|
||||
Ptr<const ptime>::Ref clipTimestamp)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
Ptr<Connection>::Ref conn;
|
||||
bool result = false;
|
||||
Ptr<const UniqueId>::Ref id;
|
||||
Ptr<Connection>::Ref conn;
|
||||
bool result = false;
|
||||
Ptr<UniqueId>::Ref id;
|
||||
|
||||
try {
|
||||
conn = cm->getConnection();
|
||||
|
@ -209,15 +209,15 @@ PostgresqlPlayLog :: addPlayLogEntry(
|
|||
/*------------------------------------------------------------------------------
|
||||
* Get the play log entries for a given time interval
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<std::vector<Ptr<const PlayLogEntry>::Ref> >::Ref
|
||||
Ptr<std::vector<Ptr<PlayLogEntry>::Ref> >::Ref
|
||||
PostgresqlPlayLog :: getPlayLogEntries(
|
||||
Ptr<const ptime>::Ref fromTime,
|
||||
Ptr<const ptime>::Ref toTime)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
Ptr<Connection>::Ref conn;
|
||||
Ptr<std::vector<Ptr<const PlayLogEntry>::Ref> >::Ref result(
|
||||
new std::vector<Ptr<const PlayLogEntry>::Ref>());
|
||||
Ptr<std::vector<Ptr<PlayLogEntry>::Ref> >::Ref result(
|
||||
new std::vector<Ptr<PlayLogEntry>::Ref>());
|
||||
|
||||
try {
|
||||
conn = cm->getConnection();
|
||||
|
@ -238,7 +238,7 @@ PostgresqlPlayLog :: getPlayLogEntries(
|
|||
Ptr<ptime>::Ref clipTimestamp
|
||||
= Conversion::timestampToPtime(timestamp);
|
||||
|
||||
Ptr<const PlayLogEntry>::Ref entry(new PlayLogEntry(id,
|
||||
Ptr<PlayLogEntry>::Ref entry(new PlayLogEntry(id,
|
||||
audioClipId,
|
||||
clipTimestamp));
|
||||
result->push_back(entry);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlPlayLog.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -81,7 +81,7 @@ using namespace LiveSupport::Core;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class PostgresqlPlayLog : public Configurable,
|
||||
public PlayLogInterface
|
||||
|
@ -202,7 +202,7 @@ class PostgresqlPlayLog : public Configurable,
|
|||
* @param timeStamp the time the clip was played (started).
|
||||
* @return the id of the newly created play log entry.
|
||||
*/
|
||||
virtual Ptr<const UniqueId>::Ref
|
||||
virtual Ptr<UniqueId>::Ref
|
||||
addPlayLogEntry(Ptr<const UniqueId>::Ref audioClipId,
|
||||
Ptr<const ptime>::Ref timeStamp)
|
||||
throw (std::invalid_argument);
|
||||
|
@ -216,7 +216,7 @@ class PostgresqlPlayLog : public Configurable,
|
|||
* non-inclusive
|
||||
* @return a vector of the play log entries for the time region.
|
||||
*/
|
||||
virtual Ptr<std::vector<Ptr<const PlayLogEntry>::Ref> >::Ref
|
||||
virtual Ptr<std::vector<Ptr<PlayLogEntry>::Ref> >::Ref
|
||||
getPlayLogEntries(Ptr<const ptime>::Ref fromTime,
|
||||
Ptr<const ptime>::Ref toTime)
|
||||
throw (std::invalid_argument);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.7 $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/XmlRpcTools.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -72,7 +72,7 @@ using namespace LiveSupport::Core;
|
|||
* in the Scheduler.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.7 $
|
||||
* @version $Revision: 1.8 $
|
||||
*/
|
||||
class XmlRpcTools
|
||||
{
|
||||
|
@ -245,8 +245,9 @@ class XmlRpcTools
|
|||
/**
|
||||
* Convert an error code, message pair to an XmlRpcValue
|
||||
*
|
||||
* @param playlist the Playlist to convert.
|
||||
* @param xmlRpcValue the output parameter holding the result of
|
||||
* @param errorCode the numerical code of the error.
|
||||
* @param errorMessage a short English description of the error.
|
||||
* @param xmlRpcValue the output parameter holding the result of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
|
@ -319,7 +320,7 @@ class XmlRpcTools
|
|||
* Convert a schedule entry ID (a UniqueId) to an XmlRpcValue
|
||||
*
|
||||
* @param scheduleEntryId the UniqueId to convert.
|
||||
* @param xmlRpcValue the output parameter holding the result of
|
||||
* @param returnValue the output parameter holding the result of
|
||||
* the conversion.
|
||||
*/
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue