Skip to content
Snippets Groups Projects
Commit a32cbe9b authored by Marcel Loose's avatar Marcel Loose :sunglasses:
Browse files

BugID: 991

Added CommandQueueTrigger class for handling database notifications.
parent e6f4e3ea
No related branches found
No related tags found
No related merge requests found
//# CommandQueueTriggers.h: Handle trigger for the BBS command queue
//#
//# Copyright (C) 2002-2007
//# ASTRON (Netherlands Foundation for Research in Astronomy)
//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
//#
//# This program 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.
//#
//# This program 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 this program; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//#
//# $Id$
#ifndef LOFAR_BBSCONTROL_COMMANDQUEUETRIGGER_H
#define LOFAR_BBSCONTROL_COMMANDQUEUETRIGGER_H
//# Never #include <config.h> or #include <lofar_config.h> in a header file!
// \file
// Handle trigger for the BBS command queue
//# Includes
#if defined(HAVE_PQXX)
# include <pqxx/trigger>
#else
# error libpqxx, the C++ API to PostgreSQL, is required
#endif
#include <Common/lofar_string.h>
namespace LOFAR
{
namespace BBS
{
//# Forward Declarations
class CommandQueue;
// \addtogroup BBSControl
// @{
// Functor class for handling in incoming trigger.
class CommandQueueTrigger : public pqxx::trigger
{
public:
// Constructor. The trigger handler will handle notifications received
// from the CommandQueue \a queue.
explicit CommandQueueTrigger(const CommandQueue& queue,
const string& name = "");
// Destructor. Reimplemented only because of no-throw specification.
virtual ~CommandQueueTrigger() throw() {}
// Handle the notification.
virtual void operator()(int be_pid);
private:
// Here we store a \e reference to the CommandQueue that will trigger
// notifications.
const CommandQueue& itsQueue;
// Name associated with this trigger handler.
const string itsName;
};
// @}
} // namespace BBS
} // namespace LOFAR
#endif
......@@ -15,6 +15,7 @@ pkginclude_HEADERS = \
Command.h \
CommandHandler.h \
CommandQueue.h \
CommandQueueTrigger.h \
CommandQueueTransactors.h \
DomainRegistrationRequest.h \
Exceptions.h \
......
//# CommandQueueTrigger.cc: Handle trigger for the BBS command queue
//#
//# Copyright (C) 2002-2007
//# ASTRON (Netherlands Foundation for Research in Astronomy)
//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
//#
//# This program 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.
//#
//# This program 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 this program; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//#
//# $Id$
//# Always #include <lofar_config.h> first!
#include <lofar_config.h>
//# Includes
#include <BBSControl/CommandQueueTrigger.h>
#include <BBSControl/CommandQueue.h>
#include <BBSControl/Exceptions.h>
#include <Common/LofarLogger.h>
#include <Common/StreamUtil.h>
#include <Common/lofar_typeinfo.h>
namespace LOFAR
{
namespace BBS
{
CommandQueueTrigger:: CommandQueueTrigger(const CommandQueue& queue,
const string& name) :
pqxx::trigger(*queue.itsConnection, name),
itsQueue(queue),
itsName(name)
{
LOG_DEBUG_STR("Created trigger handler for " << name);
}
void CommandQueueTrigger::operator()(int be_pid)
{
LOG_DEBUG_STR("Received notification: " << name() <<
"; pid = " << be_pid);
// itsQueue.blabla();
}
} // namespace BBS
} // namespace LOFAR
......@@ -15,7 +15,9 @@ libbbscontrol_la_SOURCES = \
BlobStreamableConnection.cc \
DomainRegistrationRequest.cc \
CommandQueue.cc \
CommandQueueTrigger.cc \
CommandQueueTransactors.cc \
CommandQueueTrigger.cc \
GlobalProcessControl.cc \
IterationRequest.cc \
IterationResult.cc \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment