diff --git a/MAC/APL/CEPCU/src/ApplController/ConfigurationMgr.cc b/MAC/APL/CEPCU/src/ApplController/ConfigurationMgr.cc deleted file mode 100644 index a20ebf8fa062aa5ddbed7065b12e83484025c512..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/ApplController/ConfigurationMgr.cc +++ /dev/null @@ -1,343 +0,0 @@ -//# ConfigurationMgr.cc: The ACC confMgr for all parameter manipulations -//# -//# Copyright (C) 2002-2004 -//# 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 -//# -//# TODO: support 'instances=' in appendTU -//# -//# Note: TRACE_CALC level is used for database queries -//# -//# Note:This source is read best with tabstop 4. -//# -//# $Id$ - -#include <Common/LofarLogger.h> -#include <Common/ParameterSet.h> -#include <PL/TPersistentObject.h> -#include <PL/PersistenceBroker.h> -#include <PL/Attrib.h> -#include "ConfigurationMgr.h" -#include "ParCollRecord.h" -#include "database/PO_ParCollRecord.h" - -using namespace LOFAR::PL; - -namespace LOFAR { - namespace ACC { - -//# -//# Default constructor -//# -ConfigurationMgr::ConfigurationMgr() -{ - //# TBW: connect based on parameterset values. -} - -//# -//# ConfigurationMgr(hostname, databasename, password) -//# -ConfigurationMgr::ConfigurationMgr(const string& hostname, - const string& databasename, - const string& password) -{ - itsBroker.connect(databasename, password); -} - -//# -//# Destructor -//# -ConfigurationMgr::~ConfigurationMgr() -{} - -string ConfigurationMgr::resolveVersionnr(const string& aComponent, - const string& aQualification) const -{ - // Construct a query to find the version - Query::Expr query = ( - (attrib<ParCollRecord>("name") == aComponent) && - (attrib<ParCollRecord>("qualification") == aQualification)); - ParCollRecord PCR; - TPersistentObject<ParCollRecord> tpoPCR(PCR); - - LOG_TRACE_CALC_STR("Query = " << query); - - // Get the PT from the database - ASSERTSTR(tpoPCR.retrieveInPlace(query, 1) >= 1, - "Component >" << aComponent << "<, qualification >" << - aQualification << "< not in the database!"); - - LOG_TRACE_FLOW_STR(formatString("resolveVersionnr(%s,%s)=%s", - aComponent.c_str(), aQualification.c_str(), - PCR.getVersionNr().c_str())); - - return (PCR.getVersionNr()); -} - -//# -//# Internal recursive routine: -//# appendTU(TemplateUnion, componentName, versionNr) -//# -void ConfigurationMgr::appendTU(TemplateUnion* theTU, - const string& parentname, - const string& componentName, - uint32 sequencenr, - const string& versionNr) -{ - LOG_TRACE_FLOW(formatString("appendTU:%s|%s|%d|%s", parentname.c_str(), - componentName.c_str(), sequencenr, versionNr.c_str())); - - // Construct a query to find the PT - Query::Expr query = ( - (attrib<ParCollRecord>("name") == componentName) && - (attrib<ParCollRecord>("version") == versionNr)); - ParCollRecord subTemplate; - TPersistentObject<ParCollRecord> tpoPCR(subTemplate); - - LOG_TRACE_CALC_STR("Query = " << query); - - // Get the PT from the database - ASSERTSTR(tpoPCR.retrieveInPlace(query, 1) >= 1, - "Component >" << componentName << "<, version >" << - versionNr << "< not in database!"); - - // mainComp contains whole parential hierarchy. - string mainComp(parentname); - if (mainComp != "") { // correct parentname if - mainComp += "."; // not root level - } - LOG_TRACE_VAR(formatString("mainComp=%s", mainComp.c_str())); - - // construct sequencenumber string - string seqNrStr; - if (sequencenr > 0) { - seqNrStr = formatString("%d.", sequencenr); - } - - // Walk through PT and handle the lines. - string paramLine; - uint32 offset = 0; - while (subTemplate.getLine(paramLine, &offset)) { // get next line - LOG_TRACE_VAR_STR("paramLine=" << paramLine); - - // There are four forms possible for the left part: - // componentname.parameter - // componentname.versionnr - // componentname.subcomponent.versionnr - // componentname.subcomponent.seqnr.versionnr - // - // PTcomp . PTsubcomp . PTseqnr . PTkey - // <--------- PTfullcomp ------> - - // split line into handy parts - string left (keyPart (paramLine)); // split line - string right (valuePart(paramLine)); - string PTkey (keyName (left)); - string PTfullcomp(moduleName(left)); // full component name - - if (PTkey != PC_KEY_VERSIONNR) { // parameter def? - LOG_TRACE_LOOP("Add parameterdef to TU"); // just add. - theTU->insert(make_pair(mainComp+PTfullcomp+"."+seqNrStr+PTkey, - right)); - } - else { // versionnr line - if (PTfullcomp == componentName) { // own versionnr? - LOG_TRACE_LOOP("Add own versionnr to TU"); // just add - theTU->insert(make_pair(mainComp+PTfullcomp+"."+seqNrStr+PTkey, - right)); - } - else { // Vnr of other comp. - uint32 PTseqnr = seqNr(keyName(PTfullcomp));// lst part is nr? - if (PTseqnr > 0) { - PTfullcomp = moduleName(PTfullcomp);// strip of number - } - string PTcomp(moduleName(PTfullcomp));// first block is parent - string PTsubcomp = keyName(PTfullcomp); // real comp is last part - string subCompVersion; - if ((right == PC_QUAL_STABLE) || (right == PC_QUAL_TEST) || - (right == PC_QUAL_DEVELOP)) { - // user want latest version of given qualification - subCompVersion = resolveVersionnr(PTsubcomp, right); - } - else { // 'hard' versionnr - subCompVersion = right; - } - LOG_TRACE_LOOP_STR("version of subcomponent=" << subCompVersion); - - // Call ourself to add this part of the tree - appendTU(theTU, mainComp+PTcomp+seqNrStr, PTsubcomp, - PTseqnr, subCompVersion); - } - } // versionnr line - } // while lines in template - LOG_TRACE_FLOW("appendTU return"); -} - -//# -//# createTemplateUnion (componentName, versionNr) -//# -TemplateUnion* ConfigurationMgr::createTemplateUnion(const string& componentName, - const string& versionNr) -{ - TemplateUnion* theTU = new TemplateUnion; - - appendTU (theTU, "", componentName, 0, versionNr); // recursive append - - return (theTU); -} - -//# -//# createParameterUnion (templateUnion) -//# -ParameterUnion* ConfigurationMgr::createParameterUnion(const TemplateUnion& aTU) const -{ - return(0); -} - -//# -//# createParamterSet (templateUnion, parameterUnion) -//# -ParameterSet* ConfigurationMgr::createParameterSet(const TemplateUnion& aTU, - const ParameterUnion& aPU) const -{ - return(0); -} - -//# -//# deleteTU(componentName, versionNr) -//# -bool ConfigurationMgr::deleteTU(const string& componentName, - const string& versionNr) const -{ - return(true); -} - -//# -//# deletePT (componentName, versionNr) -//# -bool ConfigurationMgr::deletePT(const string& componentName, - const string& versionNr) const -{ - return(true); -} - -//# -//# deletePS(componentName, versionNr) -//# -bool ConfigurationMgr::deletePS(const string& componentName, - const string& versionNr) const -{ - return(true); -} - - -//# -//# getTU(componentName, versionNr) -//# -TemplateUnion* ConfigurationMgr::getTU(const string& componentName, - const string& versionNr) const -{ - return(0); -} - -//# -//# getPT(componentName, versionNr) -//# -ParameterTemplate* ConfigurationMgr::getPT(const string& componentName, - const string& versionNr) const -{ - Query::Expr query = ( - (attrib<ParCollRecord>("name") == componentName) && - (attrib<ParCollRecord>("version") == versionNr)); - ParCollRecord PCR; - TPersistentObject<ParCollRecord> tpoPCR(PCR); - - LOG_TRACE_CALC_STR("Query = " << query); - - tpoPCR.retrieveInPlace(query, 1); - - ParameterTemplate* PTptr = new ParameterTemplate; - PTptr->adoptBuffer(PCR.getCollection()); - - return (PTptr); -} - -//# -//# getPS(componentName, versionNr) -//# -ParameterSet* ConfigurationMgr::getPS(const string& componentName, - const string& versionNr) const -{ - return(0); -} - - -//# -//# addTU(componentName, versionNr) -//# -bool ConfigurationMgr::addTU (TemplateUnion& aTU) const -{ - return(true); -} - -//# -//# addPT(componentName, versionNr) -//# -bool ConfigurationMgr::addPT (ParameterTemplate& aPT) const -{ - string name = aPT.getName(); - string version = aPT.getVersionNr(); - string qual = aPT.getQualification(); - - LOG_TRACE_FLOW (formatString("Saving PT %s:%s(%s)", name.c_str(), - version.c_str(), qual.c_str())); - - string contents; - aPT.writeBuffer(contents); - ParCollRecord PCRec (name, version, qual, contents); - TPersistentObject<ParCollRecord> tpoPCR(PCRec); - - itsBroker.save(tpoPCR); - - return (true); -} - -//# -//# addPS(componentName, versionNr) -//# -bool ConfigurationMgr::addPS (ParameterSet& aPS) const -{ - string name = aPS.getName(); - string version = aPS.getVersionNr(); - string qual = "development"; - - LOG_TRACE_FLOW (formatString("Saving PS %s:%s(%s)", name.c_str(), - version.c_str(), qual.c_str())); - - string contents; - aPS.writeBuffer(contents); - ParCollRecord PCRec (name, version, qual, contents); - TPersistentObject<ParCollRecord> tpoPCR(PCRec); - - itsBroker.save(tpoPCR); - - return (true); -} - - - } // namespace ACC -} // namespace LOFAR diff --git a/MAC/APL/CEPCU/src/ApplController/ConfigurationMgr.h b/MAC/APL/CEPCU/src/ApplController/ConfigurationMgr.h deleted file mode 100644 index 123fc607cbaed27ebaf835c7136a3833cd3a6c5f..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/ApplController/ConfigurationMgr.h +++ /dev/null @@ -1,101 +0,0 @@ -//# ConfigurationMgr.h: The ACC ConfMgr for all parameter manipulations -//# -//# Copyright (C) 2002-2004 -//# 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 -//# -//# Note: This source is read best with tabstop 4. -//# -//# $Id$ - -#ifndef LOFAR_ACCBIN_CONFIGURATIONMGR_H -#define LOFAR_ACCBIN_CONFIGURATIONMGR_H - -// \file -// The ACC configuration manager handles all database actions for parameters. - -//# Never #include <config.h> or #include <lofar_config.h> in a header file! -#include <Common/lofar_string.h> -#include <PL/PersistenceBroker.h> -#include <Common/ParameterSet.h> - - -namespace LOFAR { - namespace ACC { -// \addtogroup ACCbin -// @{ - -//# Description of class. -// The ConfigurationMgr is a class that performs a lot of tasks on more than -// one ParameterCollection. It is capable of converting some flavors of -// ParameterCollections in to others and can construct Unions from other -// Collections. -class ConfigurationMgr -{ -public: - // Default constructable, uses parameterfile settings. - ConfigurationMgr(); - - // Construction with overriding parameterfile settings. - ConfigurationMgr(const string& hostname, - const string& databasename, - const string& password); - - ~ConfigurationMgr(); - - // Creation of several flavors of parameter collections - TemplateUnion* createTemplateUnion (const string& componentName, - const string& versionNr); // const; - ParameterUnion* createParameterUnion(const TemplateUnion& aTU) const; - ParameterSet* createParameterSet (const TemplateUnion& aTU, - const ParameterUnion& aPU) const; - - // Delete collections from the database - bool deleteTU(const string& componentName, const string& versionNr) const; - bool deletePT(const string& componentName, const string& versionNr) const; - bool deletePS(const string& componentName, const string& versionNr) const; - - // Get collections from the database - TemplateUnion* getTU (const string& componentName, - const string& versionNr) const; - ParameterTemplate* getPT (const string& componentName, - const string& versionNr) const; - ParameterSet* getPS (const string& componentName, - const string& versionNr) const; - - // Add collections to the database - bool addTU (TemplateUnion& aTU) const; // private? - bool addPT (ParameterTemplate& aPT) const; - bool addPS (ParameterSet& aPS) const; // private? - -private: - void appendTU(TemplateUnion* aTU, - const string& treebase, - const string& componentName, - uint32 sequencenr, - const string& versionNr); - string resolveVersionnr(const string& aKey, - const string& aValue) const; - - LOFAR::PL::PersistenceBroker itsBroker; -}; - -// @} addgroup - } // namespace ACC -} // namespace LOFAR - -#endif diff --git a/MAC/APL/CEPCU/src/ApplController/DH_OTDBlog.cc b/MAC/APL/CEPCU/src/ApplController/DH_OTDBlog.cc deleted file mode 100644 index 4c61c0c6a1890f7406d2b9c07aee18d2a4ca9aba..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/ApplController/DH_OTDBlog.cc +++ /dev/null @@ -1,134 +0,0 @@ -//# DH_OTDBlog.cc: Implements the OTDB log command dataholder. -//# -//# Copyright (C) 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 -//# -//# Abstract: -//# This class implements the command protocol between an application manager -//# (MAC for instance) and an Application Controller (=ACC package). -//# The AM has the client role, the AC the server role. -//# -//# $Id$ - -#include <lofar_config.h> - -//# Includes -#include <ALC/DH_OTDBlog.h> - - -namespace LOFAR { - namespace ACC { - namespace ALC { - -// Constructor -DH_OTDBlog::DH_OTDBlog() : - DataHolder ("", "DH_OTDBlog"), - itsVersionNumber(0), -{ - LOG_TRACE_OBJ("DH_applControl()"); - setExtraBlob ("Extra", 1); -} - - -// Destructor -DH_OTDBlog::~DH_OTDBlog() -{ - LOG_TRACE_OBJ("~DH_applControl()"); -} - -// Copying is allowed. -DH_OTDBlog::DH_OTDBlog(const DH_OTDBlog& that) : - DataHolder(that), - itsVersionNumber(that.itsVersionNumber), -{ - setExtraBlob ("Extra", 1); -} - -DH_OTDBlog* DH_OTDBlog::clone() const -{ - return new DH_OTDBlog(*this); -} - -DH_OTDBlog* DH_OTDBlog::makeDataCopy() const -{ - DH_OTDBlog* newDHAC = new DH_OTDBlog; - newDHAC->init(); - newDHAC->setMessages(getMessages()); - newDHAC->pack(); - - return (newDHAC); -} - -// Redefines the init function. -void DH_OTDBlog::init() -{ - LOG_TRACE_FLOW("DH_OTDBlog:init()"); - - initDataFields(); - - addField ("VersionNumber", BlobField<uint16>(1)); - - createDataBlock(); - -} - -// Redefine the pack function. -void DH_OTDBlog::pack() -{ - LOG_TRACE_RTTI("DH_OTDBlog:pack()"); - - BlobOStream& bos = createExtraBlob(); // attached to dataholder - - bos << itsOptions; - - DataHolder::pack(); -} - -// Redefine the unpack function. -void DH_OTDBlog::unpack() -{ - LOG_TRACE_RTTI("DH_OTDBlog:unpack()"); - - DataHolder::unpack(); - - int32 version; - bool found; - BlobIStream& bis = getExtraBlob(found, version); - ASSERTSTR (found, "DH_OTDBlog::read has no extra blob"); - - bis >> itsOptions; - bis.getEnd(); -} - - -//# ---------- private ---------- - -// Implement the initialisation of the pointers -void DH_OTDBlog::fillDataPointers() { - LOG_TRACE_FLOW("DH_OTDBlog:fillDataPointers()"); - - itsVersionNumber = getData<uint16>("VersionNumber"); - - *itsVersionNumber = 0x0100; // TODO define a constant WriteVersion -} - - - } // namespace ALC - } // namespace ACC -} // namespace LOFAR - diff --git a/MAC/APL/CEPCU/src/ApplController/DH_OTDBlog.h b/MAC/APL/CEPCU/src/ApplController/DH_OTDBlog.h deleted file mode 100644 index ea316af339eb30b4d08a4ed98b93408f97ca30d0..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/ApplController/DH_OTDBlog.h +++ /dev/null @@ -1,129 +0,0 @@ -//# DH_OTDBlog.h: DataHolder for OTDB logmessages -//# -//# Copyright (C) 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 -//# -//# Note: This source is read best with tabstop 4. -//# -//# $Id$ - -#ifndef LOFAR_ACCBIN_DH_OTDBLOG_H -#define LOFAR_ACCBIN_DH_OTDBLOG_H - -// \file -// DataHolder for OTDB log messages - -//# Never #include <config.h> or #include <lofar_config.h> in a header file! -//# Includes -#include <sys/time.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <Blob/BlobIStream.h> -#include <Blob/BlobOStream.h> -#include <Transport/DataHolder.h> - -namespace LOFAR { - namespace ACC { - namespace ALC { -// \addtogroup ALC -// @{ - - -//# Description of class. -// The DH_OTDBlog class is responsible for packing and unpacking -// log messages that are exchanged between the ApplController and -// the OTDBlogger. -class DH_OTDBlog : public DataHolder -{ -public: - // Constructor - DH_OTDBlog(); - - // Destructor - virtual ~DH_OTDBlog(); - - // \name libTransport methods - // @{ - - // Register the fixed size variables to the dataholderblob. - virtual void init(); - - // Tries to fill its buffer with new data. Returns \c true is a complete - // message is received. - void unpack(); - - // Write the current contents to the network. - void pack(); - - // The clone function is neccesary to meet the libTransport requirements, - // it copies everything but the data. Something we never need. - DH_OTDBlog* clone() const; - // @} - - // \name Additional methods - // @{ - - // \c makeDataCopy is the counterpart of clone: it copies the data. - DH_OTDBlog* makeDataCopy() const; - - // @} - - // \name Data-accessor methods - // @{ - - void setMessages (const string& theMsgBuffer); - string getMessages () const; - // @} - -private: - // Copying is not allowed this way. - DH_OTDBlog(const DH_OTDBlog& that); - - // Copying is not allowed this way. - DH_OTDBlog& operator=(const DH_OTDBlog& that); - - // Implement the initialisation of the pointers - virtual void fillDataPointers(); - - //# --- DataMembers --- - uint16 *itsVersionNumber; - string itsMessageBuffer; -}; - -//# -//# setMessages(messages) -//# -inline void DH_OTDBlog::setMessages (const string& theMessages) -{ - itsMessageBuffer = theMessages; -} - -//# -//# getMessages() -//# -inline string DH_OTDBlog::getMessages () const -{ - return (itsMessageBuffer); -} - -// @} addgroup - } // namespace ALC - } // namespace ACC -} // namespace LOFAR - -#endif diff --git a/MAC/APL/CEPCU/src/ApplController/OTDBComm.cc b/MAC/APL/CEPCU/src/ApplController/OTDBComm.cc deleted file mode 100644 index 8dbb9d55133ae55cb765b97684383fec974cd15e..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/ApplController/OTDBComm.cc +++ /dev/null @@ -1,123 +0,0 @@ -//# OTDBComm.cc: Implements the communication of OTDB log messages. -//# -//# Copyright (C) 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$ - -#include <lofar_config.h> - -//# Includes -#include <Transport/TH_Socket.h> -#include <PLC/OTDBComm.h> - -namespace LOFAR { - namespace ACC { - namespace ACCbin { - -// -// client constructor -// -OTDBComm::OTDBComm(const string& hostname, - const string& port, - bool syncComm) : - itsConnection(0), - itsDataHolder(new DH_OTDBlog), - itsSyncComm(syncComm) -{ - ASSERTSTR(itsDataHolder, "Unable to allocate a dataholder"); - itsDataHolder->init(); - - TH_Socket* theTH = new TH_Socket(hostname, port, syncComm); - ASSERTSTR(theTH, "Unable to allocate a transportHolder"); - theTH->init(); - - itsConnection = new CSConnection("write", itsDataHolder, 0, theTH, syncComm); - ASSERTSTR(itsWriteConn, "Unable to allocate connection for wrtiting"); -} - -// -// server constructor -// -OTDBComm::OTDBComm(const string& port, - bool syncComm) : - itsConnection(0), - itsDataHolder(new DH_OTDBlog), - itsSyncComm(syncComm) -{ - ASSERTSTR(itsDataHolder, "Unable to allocate a dataholder"); - itsDataHolder->init(); - - TH_Socket* theTH = new TH_Socket(port, syncComm); - ASSERTSTR(theTH, "Unable to allocate a transportHolder"); - theTH->init(); - - itsReadConn = new CSConnection("read", 0, itsDataHolder, theTH, syncComm); - ASSERTSTR(itsReadConn, "Unable to allocate connection for reading"); -} - -// -// Destructor -// -OTDBComm::~OTDBComm() -{ - if (itsDataHolder) { - delete itsDataHolder; - } -} - -// -// poll() -// -// Check if a new message is available -// Note: only usefull for async communication -// -bool OTDBComm::poll() const -{ - // Never become blocking in a poll - if (itsSyncComm) { - return (false); - } - - return (itsConnection->read() == CSConnection::Finished); -} - -// -// sendLogBuffer() -// -void OTDBComm::sendLogBuffer(const string& theMessages) const -{ - itsDataHolder->setMessages(theMessages); - - itsConnection->write(); -} - -// -// getLogBuffer() -// -string OTDBComm::getLogBuffer() const -{ - return (itsDataHolder->getMessages()) -} - - - - } // namespace ACCbin - } // namespace ACC -} // namespace LOFAR - diff --git a/MAC/APL/CEPCU/src/ApplController/OTDBComm.h b/MAC/APL/CEPCU/src/ApplController/OTDBComm.h deleted file mode 100644 index cc30c2500c4a60bb31a3f237ff4701cc4b5e29e2..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/ApplController/OTDBComm.h +++ /dev/null @@ -1,91 +0,0 @@ -//# OTDBComm.h: Implements the communication of OTDB logmessages. -//# -//# Copyright (C) 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 -//# -//# Note: This source is read best with tabstop 4. -//# -//# $Id$ - -#ifndef LOFAR_ACCBIN_OTDBCOMM_H -#define LOFAR_ACCBIN_OTDBCOMM_H - -// \file -// Implements the communication of Application processes. - -//# Never #include <config.h> or #include <lofar_config.h> in a header file! -//# Includes -#include <Transport/CSConnection.h> -#include <PLC/DH_OTDBlog.h> - -namespace LOFAR { - namespace ACC { - namespace ACCbin { -// \addtogroup ACCbin -// @{ - -//# Description of class. -// The OTDBComm class implements the communication between the -// Application Controller and the OTDB logger. -class OTDBComm -{ -public: - // The client constructor - OTDBComm(const string& hostname, - const string& port, - bool syncComm); - - // The server constructor - OTDBComm(const string& port, - bool syncComm); - - // Destructor; - virtual ~OTDBComm(); - - // Constructs a command and sends it to the other side. - void sendLogBuffer(const string& theMessages) const; - - // Can be used in async communication to see if a new message has arived. - // Returns \c true in async communication because call would block. - bool poll() const; - - // Get the contents of the message (after the read was completed) - string getLogBuffer() const; - -private: - // Not default constructable and cpoying is not allowed. - OTDBComm() {} - OTDBComm(const OTDBComm& that); - OTDBComm& operator= (const OTDBComm& that); - - //# --- Datamembers --- - // Pointers to the connection objects that manage the communication - CSConnection* itsConnection; - DH_OTDBlog* itsDataHolder; - - // Synchrone or asynchrone communication. - bool itsSyncComm; - -}; - -// @} addgroup - } // namespace ACCbin - } // namespace ACC -} // namespace LOFAR - -#endif diff --git a/MAC/APL/CEPCU/src/ApplController/ParCollRecord.cc b/MAC/APL/CEPCU/src/ApplController/ParCollRecord.cc deleted file mode 100644 index 0b73cbe069d42eb18357019ce52742347d4db338..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/ApplController/ParCollRecord.cc +++ /dev/null @@ -1,59 +0,0 @@ -//# ParCollRecord.cc: ParameterCollection record for DB storage -//# -//# Copyright (C) 2002-2004 -//# 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$ - -#include <lofar_config.h> -#include "ParCollRecord.h" - -namespace LOFAR { - namespace ACC { - -ParCollRecord::ParCollRecord (const string& aName, - const string& aVersion, - const string& aQualification, - const string& aContents) : - itsName(aName), - itsVersionNr(aVersion), - itsQualification(aQualification), - itsCollection(aContents) -{ -} - - -int32 ParCollRecord::getLine(string& buffer, uint32* offset) -{ - if (*offset >= itsCollection.size()) { // reached end, reset - buffer = ""; - *offset = itsCollection.size(); - return (0); - } - - int32 eol = itsCollection.find_first_of ('\n', *offset); - int32 resultLen = eol - *offset; - buffer = itsCollection.substr(*offset, resultLen); - *offset = eol+1; - return (resultLen); -} - - - - } // namespace ACC -} // namespace LOFAR diff --git a/MAC/APL/CEPCU/src/ApplController/ParCollRecord.h b/MAC/APL/CEPCU/src/ApplController/ParCollRecord.h deleted file mode 100644 index efcdc7291d77ee7aef61647ee7facfe63085abb7..0000000000000000000000000000000000000000 --- a/MAC/APL/CEPCU/src/ApplController/ParCollRecord.h +++ /dev/null @@ -1,70 +0,0 @@ -//# ParCollRecord.h: structure how PC's are stored in the DB -//# -//# Copyright (C) 2002-2004 -//# 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 -//# -//# Note: This source is read best with tabstop 4. -//# -//# $Id$ - -#ifndef LOFAR_ACCBIN_PARCOLLRECORD_H -#define LOFAR_ACCBIN_PARCOLLRECORD_H - -// \file -// Structure how PC's are stored in the DB - -//# Never #include <config.h> or #include <lofar_config.h> in a header file! -//# Includes -#include <Common/lofar_string.h> -#include <PL/TPersistentObject.h> -#include <dtl/dtl_config.h> - -using dtl::blob; - -namespace LOFAR { - namespace ACC { -// \addtogroup ACCbin -// @{ - -// Structure how PC's are stored in the DB -class ParCollRecord -{ -public: - ParCollRecord () {}; - ParCollRecord (const string& aName, - const string& aVersion, - const string& Aqualification, - const string& aContents); - int32 getLine(string& buffer, uint32* bufLen); - inline string getCollection() { return (itsCollection); } - inline string getVersionNr() { return (itsVersionNr); } - -private: - friend class LOFAR::PL::TPersistentObject<ParCollRecord>; - - string itsName; - string itsVersionNr; - string itsQualification; - string itsCollection; -}; - -// @} addgroup -} // namespace ACC -} // namespace LOFAR - -#endif