Octave Interface: Rolled out use of common constant for DataStreamVersion

p4#: 21689
This commit is contained in:
Jacob Støren
2013-05-22 09:18:57 +02:00
parent 4b7ff209f6
commit 90e61c254b
7 changed files with 55 additions and 29 deletions

View File

@@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight 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 3 of the License, or
// (at your option) any later version.
//
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
//////////////////////////////////////////////////////////////////////////
/// Socket commands, to be moved into a separate file
//////////////////////////////////////////////////////////////////////////
class RiaSocketCommand
{
public:
virtual ~RiaSocketCommand() {}
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) = 0;
virtual bool interpretMore(QDataStream& stream) { return true; }
};
#include "cafFactory.h"
typedef caf::Factory<RiaSocketCommand, QString> RiaSocketCommandFactory;
void getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId);

View File

@@ -17,7 +17,7 @@
#include "RiaStdInclude.h" #include "RiaStdInclude.h"
#include "RiaSocketServer.h" #include "RiaSocketServer.h"
#include "RiaSocketCommand.h"
#include "RimReservoirView.h" #include "RimReservoirView.h"
#include "RimResultSlot.h" #include "RimResultSlot.h"

View File

@@ -17,6 +17,7 @@
#include "RiaStdInclude.h" #include "RiaStdInclude.h"
#include "RiaSocketServer.h" #include "RiaSocketServer.h"
#include "RiaSocketCommand.h"
#include <QtGui> #include <QtGui>
#include <QtNetwork> #include <QtNetwork>
@@ -578,10 +579,10 @@ public:
static bool RiaGetActiveCellInfo_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetActiveCellInfo>(RiaGetActiveCellInfo::commandName()); static bool RiaGetActiveCellInfo_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetActiveCellInfo>(RiaGetActiveCellInfo::commandName());
class RiaGetProperty: public RiaSocketCommand class RiaGetActiveCellProperty: public RiaSocketCommand
{ {
public: public:
static QString commandName () { return QString("GetProperty"); } static QString commandName () { return QString("GetActiveCellProperty"); }
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
{ {
@@ -723,7 +724,7 @@ public:
} }
}; };
static bool RiaGetProperty_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetProperty>(RiaGetProperty::commandName()); static bool RiaGetActiveCellProperty_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetActiveCellProperty>(RiaGetActiveCellProperty::commandName());
@@ -885,7 +886,7 @@ RimCase* RiaSocketServer::findReservoir(int caseId)
void RiaSocketServer::readCommandFromOctave() void RiaSocketServer::readCommandFromOctave()
{ {
QDataStream socketStream(m_currentClient); QDataStream socketStream(m_currentClient);
socketStream.setVersion(QDataStream::Qt_4_0); socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
// If we have not read the currentCommandSize // If we have not read the currentCommandSize
// read the size of the command if all the data is available // read the size of the command if all the data is available
@@ -1025,7 +1026,7 @@ void RiaSocketServer::readCommandFromOctave()
void RiaSocketServer::readPropertyDataFromOctave() void RiaSocketServer::readPropertyDataFromOctave()
{ {
QDataStream socketStream(m_currentClient); QDataStream socketStream(m_currentClient);
socketStream.setVersion(QDataStream::Qt_4_0); socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
// If we have not read the header and there are data enough: Read it. // If we have not read the header and there are data enough: Read it.
// Do nothing if we have not enough data // Do nothing if we have not enough data

View File

@@ -20,6 +20,7 @@
#include <QObject> #include <QObject>
#include <vector> #include <vector>
#include <QDataStream>
class QLabel; class QLabel;
class QPushButton; class QPushButton;
@@ -30,6 +31,10 @@ class QErrorMessage;
class RimCase; class RimCase;
class RiaSocketCommand; class RiaSocketCommand;
namespace riOctavePlugin
{
const int qtDataStreamVersion = QDataStream::Qt_4_0;
}
class RiaSocketServer : public QObject class RiaSocketServer : public QObject
{ {
@@ -83,22 +88,3 @@ private:
bool m_invalidActiveCellCountDetected; bool m_invalidActiveCellCountDetected;
}; };
//////////////////////////////////////////////////////////////////////////
/// Socket commands, to be moved into a separate file
//////////////////////////////////////////////////////////////////////////
class RiaSocketCommand
{
public:
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) = 0;
virtual bool interpretMore(QDataStream& stream) { return true; }
};
#include "cafFactory.h"
typedef caf::Factory<RiaSocketCommand, QString> RiaSocketCommandFactory;
void getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QString& caseName, QString& caseType, qint64& caseGroupId);

View File

@@ -26,7 +26,7 @@ void getActiveCellInfo(int32NDArray& activeCellInfo, const QString &hostName, qu
QByteArray cmdBytes = command.toLatin1(); QByteArray cmdBytes = command.toLatin1();
QDataStream socketStream(&socket); QDataStream socketStream(&socket);
socketStream.setVersion(QDataStream::Qt_4_0); socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
socketStream << (qint64)(cmdBytes.size()); socketStream << (qint64)(cmdBytes.size());
socket.write(cmdBytes); socket.write(cmdBytes);

View File

@@ -1,5 +1,6 @@
#include <QtNetwork> #include <QtNetwork>
#include <octave/oct.h> #include <octave/oct.h>
#include "riSettings.h"
void setEclipseProperty(const Matrix& propertyFrames, const QString &hostName, quint16 port, QString caseName, QString propertyName) void setEclipseProperty(const Matrix& propertyFrames, const QString &hostName, quint16 port, QString caseName, QString propertyName)
@@ -25,7 +26,7 @@ void setEclipseProperty(const Matrix& propertyFrames, const QString &hostName, q
QByteArray cmdBytes = command.toLatin1(); QByteArray cmdBytes = command.toLatin1();
QDataStream socketStream(&socket); QDataStream socketStream(&socket);
socketStream.setVersion(QDataStream::Qt_4_0); socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
socketStream << (qint64)(cmdBytes.size()); socketStream << (qint64)(cmdBytes.size());
socket.write(cmdBytes); socket.write(cmdBytes);

View File

@@ -16,12 +16,12 @@
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "../ApplicationCode/SocketInterface/RiaSocketServer.h"
namespace riOctavePlugin namespace riOctavePlugin
{ {
const int timeOutMilliSecs = 5000; const int timeOutMilliSecs = 5000;
const int qtDataStreamVersion = QDataStream::Qt_4_0;
// Octave data structure : CaseInfo // Octave data structure : CaseInfo
char caseInfo_CaseId[] = "CaseId"; char caseInfo_CaseId[] = "CaseId";
char caseInfo_CaseName[] = "CaseName"; char caseInfo_CaseName[] = "CaseName";