mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-21 14:42:51 +01:00
added tableupdater
This commit is contained in:
parent
219df2e999
commit
3e1eff1b53
@ -673,6 +673,10 @@
|
|||||||
RelativePath=".\include\Poco\WebWidgets\Panel.h"
|
RelativePath=".\include\Poco\WebWidgets\Panel.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\WebWidgets\PeriodicUpdater.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\Poco\WebWidgets\ProgressIndicator.h"
|
RelativePath=".\include\Poco\WebWidgets\ProgressIndicator.h"
|
||||||
>
|
>
|
||||||
@ -697,6 +701,10 @@
|
|||||||
RelativePath=".\include\Poco\WebWidgets\TableModel.h"
|
RelativePath=".\include\Poco\WebWidgets\TableModel.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\WebWidgets\TableUpdater.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\Poco\WebWidgets\TabView.h"
|
RelativePath=".\include\Poco\WebWidgets\TabView.h"
|
||||||
>
|
>
|
||||||
@ -741,6 +749,10 @@
|
|||||||
RelativePath=".\src\Panel.cpp"
|
RelativePath=".\src\Panel.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\PeriodicUpdater.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\ProgressIndicator.cpp"
|
RelativePath=".\src\ProgressIndicator.cpp"
|
||||||
>
|
>
|
||||||
@ -765,6 +777,10 @@
|
|||||||
RelativePath=".\src\TableModel.cpp"
|
RelativePath=".\src\TableModel.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\TableUpdater.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\TabView.cpp"
|
RelativePath=".\src\TabView.cpp"
|
||||||
>
|
>
|
||||||
|
@ -670,6 +670,10 @@
|
|||||||
RelativePath=".\include\Poco\WebWidgets\Panel.h"
|
RelativePath=".\include\Poco\WebWidgets\Panel.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\WebWidgets\PeriodicUpdater.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\Poco\WebWidgets\ProgressIndicator.h"
|
RelativePath=".\include\Poco\WebWidgets\ProgressIndicator.h"
|
||||||
>
|
>
|
||||||
@ -694,6 +698,10 @@
|
|||||||
RelativePath=".\include\Poco\WebWidgets\TableModel.h"
|
RelativePath=".\include\Poco\WebWidgets\TableModel.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\WebWidgets\TableUpdater.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\Poco\WebWidgets\TabView.h"
|
RelativePath=".\include\Poco\WebWidgets\TabView.h"
|
||||||
>
|
>
|
||||||
@ -738,6 +746,10 @@
|
|||||||
RelativePath=".\src\Panel.cpp"
|
RelativePath=".\src\Panel.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\PeriodicUpdater.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\ProgressIndicator.cpp"
|
RelativePath=".\src\ProgressIndicator.cpp"
|
||||||
>
|
>
|
||||||
@ -762,6 +774,10 @@
|
|||||||
RelativePath=".\src\TableModel.cpp"
|
RelativePath=".\src\TableModel.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\TableUpdater.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\TabView.cpp"
|
RelativePath=".\src\TabView.cpp"
|
||||||
>
|
>
|
||||||
|
135
WebWidgets/include/Poco/WebWidgets/PeriodicUpdater.h
Normal file
135
WebWidgets/include/Poco/WebWidgets/PeriodicUpdater.h
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
//
|
||||||
|
// PeriodicUpdater.h
|
||||||
|
//
|
||||||
|
// $Id: //poco/Main/WebWidgets/include/Poco/WebWidgets/PeriodicUpdater.h#4 $
|
||||||
|
//
|
||||||
|
// Library: WebWidgets
|
||||||
|
// Package: Views
|
||||||
|
// Module: PeriodicUpdater
|
||||||
|
//
|
||||||
|
// Definition of the PeriodicUpdater class.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||||
|
// and Contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
// obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
// this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
// execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
// Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
// do so, all subject to the following:
|
||||||
|
//
|
||||||
|
// The copyright notices in the Software and this entire statement, including
|
||||||
|
// the above license grant, this restriction and the following disclaimer,
|
||||||
|
// must be included in all copies of the Software, in whole or in part, and
|
||||||
|
// all derivative works of the Software, unless such copies or derivative
|
||||||
|
// works are solely in the form of machine-executable object code generated by
|
||||||
|
// a source language processor.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef WebWidgets_PeriodicUpdater_INCLUDED
|
||||||
|
#define WebWidgets_PeriodicUpdater_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include "Poco/WebWidgets/WebWidgets.h"
|
||||||
|
#include "Poco/WebWidgets/TableUpdater.h"
|
||||||
|
#include "Poco/RefCountedObject.h"
|
||||||
|
#include "Poco/AutoPtr.h"
|
||||||
|
#include "Poco/Timer.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Poco {
|
||||||
|
namespace WebWidgets {
|
||||||
|
class Table;
|
||||||
|
|
||||||
|
|
||||||
|
class WebWidgets_API PeriodicUpdater: public TableUpdater
|
||||||
|
/// PeriodicUpdater periodically calls update on its inner child
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef Poco::AutoPtr<PeriodicUpdater> Ptr;
|
||||||
|
|
||||||
|
PeriodicUpdater(TableUpdater::Ptr pUpdater, Poco::UInt32 interValInSeconds);
|
||||||
|
/// Creates the PeriodicUpdater for the given table
|
||||||
|
|
||||||
|
void update();
|
||||||
|
/// Updates the table from a given source
|
||||||
|
|
||||||
|
TableModel::Ptr model();
|
||||||
|
|
||||||
|
const TableModel::Ptr model() const;
|
||||||
|
|
||||||
|
void start();
|
||||||
|
/// Starts auto updating
|
||||||
|
|
||||||
|
void stop();
|
||||||
|
/// Stops auto updating
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~PeriodicUpdater();
|
||||||
|
/// Destroys the PeriodicUpdater.
|
||||||
|
|
||||||
|
void updateTimer(Poco::Timer& timer);
|
||||||
|
|
||||||
|
private:
|
||||||
|
TableUpdater::Ptr _pUpdater;
|
||||||
|
Poco::UInt32 _interValInSeconds;
|
||||||
|
Poco::Timer _timer;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Inlines
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
inline void PeriodicUpdater::update()
|
||||||
|
{
|
||||||
|
return _pUpdater->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline TableModel::Ptr PeriodicUpdater::model()
|
||||||
|
{
|
||||||
|
return _pUpdater->model();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const TableModel::Ptr PeriodicUpdater::model() const
|
||||||
|
{
|
||||||
|
return _pUpdater->model();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void PeriodicUpdater::start()
|
||||||
|
{
|
||||||
|
TimerCallback<PeriodicUpdater> callback(*this, &PeriodicUpdater::updateTimer);
|
||||||
|
_timer.start(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void PeriodicUpdater::stop()
|
||||||
|
{
|
||||||
|
_timer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void PeriodicUpdater::updateTimer(Poco::Timer&)
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} } // namespace Poco::WebWidgets
|
||||||
|
|
||||||
|
|
||||||
|
#endif // WebWidgets_PeriodicUpdater_INCLUDED
|
102
WebWidgets/include/Poco/WebWidgets/TableUpdater.h
Normal file
102
WebWidgets/include/Poco/WebWidgets/TableUpdater.h
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
//
|
||||||
|
// TableUpdater.h
|
||||||
|
//
|
||||||
|
// $Id: //poco/Main/WebWidgets/include/Poco/WebWidgets/TableUpdater.h#4 $
|
||||||
|
//
|
||||||
|
// Library: WebWidgets
|
||||||
|
// Package: Views
|
||||||
|
// Module: TableUpdater
|
||||||
|
//
|
||||||
|
// Definition of the TableUpdater class.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||||
|
// and Contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
// obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
// this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
// execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
// Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
// do so, all subject to the following:
|
||||||
|
//
|
||||||
|
// The copyright notices in the Software and this entire statement, including
|
||||||
|
// the above license grant, this restriction and the following disclaimer,
|
||||||
|
// must be included in all copies of the Software, in whole or in part, and
|
||||||
|
// all derivative works of the Software, unless such copies or derivative
|
||||||
|
// works are solely in the form of machine-executable object code generated by
|
||||||
|
// a source language processor.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef WebWidgets_TableUpdater_INCLUDED
|
||||||
|
#define WebWidgets_TableUpdater_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include "Poco/WebWidgets/WebWidgets.h"
|
||||||
|
#include "Poco/WebWidgets/TableModel.h"
|
||||||
|
#include "Poco/RefCountedObject.h"
|
||||||
|
#include "Poco/AutoPtr.h"
|
||||||
|
#include "Poco/Any.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Poco {
|
||||||
|
namespace WebWidgets {
|
||||||
|
class Table;
|
||||||
|
|
||||||
|
|
||||||
|
class WebWidgets_API TableUpdater: public Poco::RefCountedObject
|
||||||
|
/// TableUpdater defines the interface for data retrieval for a Table
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef Poco::AutoPtr<TableUpdater> Ptr;
|
||||||
|
|
||||||
|
TableUpdater(TableModel::Ptr pModel);
|
||||||
|
/// Creates the TableUpdater for the given table
|
||||||
|
|
||||||
|
virtual void update() = 0;
|
||||||
|
/// Updates the table from a given source
|
||||||
|
|
||||||
|
virtual TableModel::Ptr model();
|
||||||
|
|
||||||
|
virtual const TableModel::Ptr model() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TableUpdater();
|
||||||
|
/// Creates the TableUpdater
|
||||||
|
|
||||||
|
virtual ~TableUpdater();
|
||||||
|
/// Destroys the TableUpdater.
|
||||||
|
|
||||||
|
private:
|
||||||
|
TableModel::Ptr _pModel;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Inlines
|
||||||
|
//
|
||||||
|
|
||||||
|
inline TableModel::Ptr TableUpdater::model()
|
||||||
|
{
|
||||||
|
return _pModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const TableModel::Ptr TableUpdater::model() const
|
||||||
|
{
|
||||||
|
return _pModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} } // namespace Poco::WebWidgets
|
||||||
|
|
||||||
|
|
||||||
|
#endif // WebWidgets_TableUpdater_INCLUDED
|
65
WebWidgets/src/PeriodicUpdater.cpp
Normal file
65
WebWidgets/src/PeriodicUpdater.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
//
|
||||||
|
// PeriodicUpdater.cpp
|
||||||
|
//
|
||||||
|
// $Id: //poco/Main/WebWidgets/src/PeriodicUpdater.cpp#3 $
|
||||||
|
//
|
||||||
|
// Library: WebWidgets
|
||||||
|
// Package: Views
|
||||||
|
// Module: PeriodicUpdater
|
||||||
|
//
|
||||||
|
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||||
|
// and Contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
// obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
// this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
// execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
// Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
// do so, all subject to the following:
|
||||||
|
//
|
||||||
|
// The copyright notices in the Software and this entire statement, including
|
||||||
|
// the above license grant, this restriction and the following disclaimer,
|
||||||
|
// must be included in all copies of the Software, in whole or in part, and
|
||||||
|
// all derivative works of the Software, unless such copies or derivative
|
||||||
|
// works are solely in the form of machine-executable object code generated by
|
||||||
|
// a source language processor.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#include "Poco/WebWidgets/PeriodicUpdater.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Poco {
|
||||||
|
namespace WebWidgets {
|
||||||
|
|
||||||
|
|
||||||
|
PeriodicUpdater::PeriodicUpdater(TableUpdater::Ptr pUpdater, Poco::UInt32 interValInSeconds):
|
||||||
|
_pUpdater(pUpdater),
|
||||||
|
_interValInSeconds(interValInSeconds),
|
||||||
|
_timer(0, interValInSeconds*1000)
|
||||||
|
{
|
||||||
|
poco_check_ptr (_pUpdater);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PeriodicUpdater::~PeriodicUpdater()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} } // namespace Poco::WebWidgets
|
62
WebWidgets/src/TableUpdater.cpp
Normal file
62
WebWidgets/src/TableUpdater.cpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
//
|
||||||
|
// TableUpdater.cpp
|
||||||
|
//
|
||||||
|
// $Id: //poco/Main/WebWidgets/src/TableUpdater.cpp#3 $
|
||||||
|
//
|
||||||
|
// Library: WebWidgets
|
||||||
|
// Package: Views
|
||||||
|
// Module: TableUpdater
|
||||||
|
//
|
||||||
|
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||||
|
// and Contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
// obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
// this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
// execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
// Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
// do so, all subject to the following:
|
||||||
|
//
|
||||||
|
// The copyright notices in the Software and this entire statement, including
|
||||||
|
// the above license grant, this restriction and the following disclaimer,
|
||||||
|
// must be included in all copies of the Software, in whole or in part, and
|
||||||
|
// all derivative works of the Software, unless such copies or derivative
|
||||||
|
// works are solely in the form of machine-executable object code generated by
|
||||||
|
// a source language processor.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#include "Poco/WebWidgets/TableUpdater.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Poco {
|
||||||
|
namespace WebWidgets {
|
||||||
|
|
||||||
|
|
||||||
|
TableUpdater::TableUpdater():
|
||||||
|
_pModel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TableUpdater::TableUpdater(TableModel::Ptr pModel):
|
||||||
|
_pModel(pModel)
|
||||||
|
{
|
||||||
|
poco_check_ptr (_pModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TableUpdater::~TableUpdater()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} } // namespace Poco::WebWidgets
|
Loading…
x
Reference in New Issue
Block a user