<commit_before>/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.

  This software is distributed WITHOUT ANY WARRANTY; without even
  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "otbUnConstrainedLeastSquareImageFilter.h"
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
#include "otbStreamingImageFileWriter.h"
#include "otbVectorImageToMatrixImageFilter.h"
#include "otbStandardWriterWatcher.h"

const unsigned int Dimension = 2;
typedef double PixelType;

typedef otb::VectorImage<PixelType, Dimension> ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::UnConstrainedLeastSquareImageFilter<ImageType,ImageType,double> UnConstrainedLeastSquareSolverType;
typedef otb::VectorImageToMatrixImageFilter<ImageType> VectorImageToMatrixImageFilterType;
typedef otb::StreamingImageFileWriter<ImageType> WriterType;

int otbUnConstrainedLeastSquareImageFilterNewTest(int argc, char * argv[])
{
  UnConstrainedLeastSquareSolverType::Pointer filter = UnConstrainedLeastSquareSolverType::New();
  std::cout << filter << std::endl;
  return EXIT_SUCCESS;
}

int otbUnConstrainedLeastSquareImageFilterTest(int argc, char * argv[])
{
  const char * inputImage = argv[1];
  const char * inputEndmembers = argv[2];
  const char * outputImage = argv[3];

  ReaderType::Pointer readerImage = ReaderType::New();
  readerImage->SetFileName(inputImage);

  ReaderType::Pointer readerEndMembers = ReaderType::New();
  readerEndMembers->SetFileName(inputEndmembers);
  VectorImageToMatrixImageFilterType::Pointer endMember2Matrix = VectorImageToMatrixImageFilterType::New();
  endMember2Matrix->SetInput(readerEndMembers->GetOutput());

  endMember2Matrix->Update();

  typedef VectorImageToMatrixImageFilterType::MatrixType MatrixType;
  MatrixType endMembers = endMember2Matrix->GetMatrix();
  MatrixType pinv = vnl_matrix_inverse<PixelType>(endMembers);

  UnConstrainedLeastSquareSolverType::Pointer unmixer = \
      UnConstrainedLeastSquareSolverType::New();

  unmixer->SetInput(readerImage->GetOutput());
  unmixer->SetMatrix(endMember2Matrix->GetMatrix());

  unmixer->Update();

  WriterType::Pointer writer = WriterType::New();
  writer->SetFileName(outputImage);
  writer->SetInput(unmixer->GetOutput());

  otb::StandardWriterWatcher w4(writer,unmixer,"UnConstrainedLeastSquareImageFilter");
  writer->Update();

  return EXIT_SUCCESS;
}
<commit_msg>TEST: remove unneeded Update call and inverse computation<commit_after>/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.

  This software is distributed WITHOUT ANY WARRANTY; without even
  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "otbUnConstrainedLeastSquareImageFilter.h"
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
#include "otbStreamingImageFileWriter.h"
#include "otbVectorImageToMatrixImageFilter.h"
#include "otbStandardWriterWatcher.h"

const unsigned int Dimension = 2;
typedef double PixelType;

typedef otb::VectorImage<PixelType, Dimension> ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::UnConstrainedLeastSquareImageFilter<ImageType,ImageType,double> UnConstrainedLeastSquareSolverType;
typedef otb::VectorImageToMatrixImageFilter<ImageType> VectorImageToMatrixImageFilterType;
typedef otb::StreamingImageFileWriter<ImageType> WriterType;

int otbUnConstrainedLeastSquareImageFilterNewTest(int argc, char * argv[])
{
  UnConstrainedLeastSquareSolverType::Pointer filter = UnConstrainedLeastSquareSolverType::New();
  std::cout << filter << std::endl;
  return EXIT_SUCCESS;
}

int otbUnConstrainedLeastSquareImageFilterTest(int argc, char * argv[])
{
  const char * inputImage = argv[1];
  const char * inputEndmembers = argv[2];
  const char * outputImage = argv[3];

  ReaderType::Pointer readerImage = ReaderType::New();
  readerImage->SetFileName(inputImage);

  ReaderType::Pointer readerEndMembers = ReaderType::New();
  readerEndMembers->SetFileName(inputEndmembers);
  VectorImageToMatrixImageFilterType::Pointer endMember2Matrix = VectorImageToMatrixImageFilterType::New();
  endMember2Matrix->SetInput(readerEndMembers->GetOutput());

  endMember2Matrix->Update();

  typedef VectorImageToMatrixImageFilterType::MatrixType MatrixType;
  MatrixType endMembers = endMember2Matrix->GetMatrix();

  UnConstrainedLeastSquareSolverType::Pointer unmixer = \
      UnConstrainedLeastSquareSolverType::New();

  unmixer->SetInput(readerImage->GetOutput());
  unmixer->SetMatrix(endMember2Matrix->GetMatrix());

  WriterType::Pointer writer = WriterType::New();
  writer->SetFileName(outputImage);
  writer->SetInput(unmixer->GetOutput());

  otb::StandardWriterWatcher w4(writer,unmixer,"UnConstrainedLeastSquareImageFilter");
  writer->Update();

  return EXIT_SUCCESS;
}
<|endoftext|>


<commit_before>#include "../Outer_Parameters.hxx"

boost::property_tree::ptree to_property_tree(const Outer_Parameters &p)
{
  boost::property_tree::ptree result(to_property_tree(p.solver));

  result.put("sdp", p.functions_path.string());
  result.put("outDir", p.output_path.string());
  result.put("noFinalCheckpoint", p.no_final_checkpoint);
  result.put("dualityGapReduction", p.duality_gap_reduction);
  result.put("writeSolution", p.write_solution);
  result.put("verbosity", static_cast<int>(p.verbosity));

  return result;
}
<commit_msg>Fix Output_Parameters serializaton into a property tree<commit_after>#include "../Outer_Parameters.hxx"

boost::property_tree::ptree to_property_tree(const Outer_Parameters &p)
{
  boost::property_tree::ptree result(to_property_tree(p.solver));

  result.put("functions", p.functions_path.string());
  result.put("points", p.points_path.string());
  result.put("out", p.output_path.string());
  result.put("noFinalCheckpoint", p.no_final_checkpoint);
  result.put("dualityGapReduction", p.duality_gap_reduction);
  result.put("writeSolution", p.write_solution);
  result.put("verbosity", static_cast<int>(p.verbosity));

  return result;
}
<|endoftext|>


<commit_before>/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
#include "genericdirectuploadservice.h"

#include "deployablefile.h"

#include <utils/qtcassert.h>
#include <utils/ssh/sftpchannel.h>
#include <utils/ssh/sshconnection.h>
#include <utils/ssh/sshremoteprocess.h>

#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QList>
#include <QtCore/QString>

using namespace Utils;

namespace RemoteLinux {
namespace Internal {
namespace {
enum State { Inactive, InitializingSftp, Uploading };
} // anonymous namespace

class GenericDirectUploadServicePrivate
{
public:
    GenericDirectUploadServicePrivate() : stopRequested(false), state(Inactive) {}

    bool stopRequested;
    State state;
    QList<DeployableFile> filesToUpload;
    SftpChannel::Ptr uploader;
    SshRemoteProcess::Ptr mkdirProc;
    SshRemoteProcess::Ptr lnProc;
    QList<DeployableFile> deployableFiles;
};

} // namespace Internal

using namespace Internal;

GenericDirectUploadService::GenericDirectUploadService(QObject *parent)
    : AbstractRemoteLinuxDeployService(parent), m_d(new GenericDirectUploadServicePrivate)
{
}

void GenericDirectUploadService::setDeployableFiles(const QList<DeployableFile> &deployableFiles)
{
    m_d->deployableFiles = deployableFiles;
}

bool GenericDirectUploadService::isDeploymentNecessary() const
{
    m_d->filesToUpload.clear();
    for (int i = 0; i < m_d->deployableFiles.count(); ++i)
        checkDeploymentNeeded(m_d->deployableFiles.at(i));
    return !m_d->filesToUpload.isEmpty();
}

void GenericDirectUploadService::doDeviceSetup()
{
    QTC_ASSERT(m_d->state == Inactive, return);

    handleDeviceSetupDone(true);
}

void GenericDirectUploadService::stopDeviceSetup()
{
    QTC_ASSERT(m_d->state == Inactive, return);

    handleDeviceSetupDone(false);
}

void GenericDirectUploadService::doDeploy()
{
    QTC_ASSERT(m_d->state == Inactive, setFinished(); return);

    m_d->uploader = connection()->createSftpChannel();
    connect(m_d->uploader.data(), SIGNAL(initialized()), SLOT(handleSftpInitialized()));
    connect(m_d->uploader.data(), SIGNAL(initializationFailed(QString)),
        SLOT(handleSftpInitializationFailed(QString)));
    m_d->uploader->initialize();
    m_d->state = InitializingSftp;
}

void GenericDirectUploadService::handleSftpInitialized()
{
    QTC_ASSERT(m_d->state == InitializingSftp, setFinished(); return);

    if (m_d->stopRequested) {
        setFinished();
        handleDeploymentDone();
        return;
    }

    Q_ASSERT(!m_d->filesToUpload.isEmpty());
    connect(m_d->uploader.data(), SIGNAL(finished(Utils::SftpJobId, QString)),
        SLOT(handleUploadFinished(Utils::SftpJobId,QString)));
    m_d->state = Uploading;
    uploadNextFile();
}

void GenericDirectUploadService::handleSftpInitializationFailed(const QString &message)
{
    QTC_ASSERT(m_d->state == InitializingSftp, setFinished(); return);

    emit errorMessage(tr("SFTP initialization failed: %1").arg(message));
    setFinished();
    handleDeploymentDone();
}

void GenericDirectUploadService::handleUploadFinished(Utils::SftpJobId jobId, const QString &errorMsg)
{
    Q_UNUSED(jobId);

    QTC_ASSERT(m_d->state == Uploading, setFinished(); return);

    if (m_d->stopRequested) {
        setFinished();
        handleDeploymentDone();
    }

    const DeployableFile d = m_d->filesToUpload.takeFirst();
    if (!errorMsg.isEmpty()) {
        emit errorMessage(tr("Upload of file '%1' failed: %2")
            .arg(QDir::toNativeSeparators(d.localFilePath), errorMsg));
        setFinished();
        handleDeploymentDone();
    } else {
        saveDeploymentTimeStamp(d);

        // Terrible hack for Windows.
        if (d.remoteDir.contains(QLatin1String("bin"))) {
            const QString remoteFilePath = d.remoteDir + QLatin1Char('/')
                + QFileInfo(d.localFilePath).fileName();
            const QString command = QLatin1String("chmod a+x ") + remoteFilePath;
            connection()->createRemoteProcess(command.toUtf8())->start();
        }

        uploadNextFile();
    }
}

void GenericDirectUploadService::handleLnFinished(int exitStatus)
{
    QTC_ASSERT(m_d->state == Uploading, setFinished(); return);

    if (m_d->stopRequested) {
        setFinished();
        handleDeploymentDone();
    }

    const DeployableFile d = m_d->filesToUpload.takeFirst();
    const QString nativePath = QDir::toNativeSeparators(d.localFilePath);
    if (exitStatus != SshRemoteProcess::ExitedNormally || m_d->lnProc->exitCode() != 0) {
        emit errorMessage(tr("Failed to upload file '%1'.").arg(nativePath));
        setFinished();
        handleDeploymentDone();
        return;
    } else {
        saveDeploymentTimeStamp(d);
        uploadNextFile();
    }
}

void GenericDirectUploadService::handleMkdirFinished(int exitStatus)
{
    QTC_ASSERT(m_d->state == Uploading, setFinished(); return);

    if (m_d->stopRequested) {
        setFinished();
        handleDeploymentDone();
    }

    const DeployableFile &d = m_d->filesToUpload.first();
    QFileInfo fi(d.localFilePath);
    const QString nativePath = QDir::toNativeSeparators(d.localFilePath);
    if (exitStatus != SshRemoteProcess::ExitedNormally || m_d->mkdirProc->exitCode() != 0) {
        emit errorMessage(tr("Failed to upload file '%1'.").arg(nativePath));
        setFinished();
        handleDeploymentDone();
    } else if (fi.isDir()) {
        saveDeploymentTimeStamp(d);
        m_d->filesToUpload.removeFirst();
        uploadNextFile();
    } else {
        const QString remoteFilePath = d.remoteDir + QLatin1Char('/')  + fi.fileName();
        if (fi.isSymLink()) {
             const QString target = fi.dir().relativeFilePath(fi.symLinkTarget()); // see QTBUG-5817.
             const QString command = QLatin1String("ln -vsf ") + target + QLatin1Char(' ')
                 + remoteFilePath;

             // See comment in SftpChannel::createLink as to why we can't use it.
             m_d->lnProc = connection()->createRemoteProcess(command.toUtf8());
             connect(m_d->lnProc.data(), SIGNAL(closed(int)), SLOT(handleLnFinished(int)));
             connect(m_d->lnProc.data(), SIGNAL(outputAvailable(QByteArray)),
                 SLOT(handleStdOutData(QByteArray)));
             connect(m_d->lnProc.data(), SIGNAL(errorOutputAvailable(QByteArray)),
                 SLOT(handleStdErrData(QByteArray)));
             m_d->lnProc->start();
        } else {
            const SftpJobId job = m_d->uploader->uploadFile(d.localFilePath, remoteFilePath,
                SftpOverwriteExisting);
            if (job == SftpInvalidJob) {
                emit errorMessage(tr("Failed to upload file '%1': "
                    "Could not open for reading.").arg(nativePath));
                setFinished();
                handleDeploymentDone();
            }
        }
    }
}

void GenericDirectUploadService::handleStdOutData(const QByteArray &data)
{
    emit stdOutData(QString::fromUtf8(data));
}

void GenericDirectUploadService::handleStdErrData(const QByteArray &data)
{
    emit stdErrData(QString::fromUtf8(data));
}

void GenericDirectUploadService::stopDeployment()
{
    QTC_ASSERT(m_d->state == InitializingSftp || m_d->state == Uploading, setFinished(); return);

    setFinished();
    handleDeploymentDone();
}

// Note: time stamp checks disabled for now; it's too much hassle for the user to force
// deployment in case the device has changed.
void GenericDirectUploadService::checkDeploymentNeeded(const DeployableFile &deployable) const
{
    QFileInfo fileInfo(deployable.localFilePath);
    if (fileInfo.isDir()) {
        const QStringList files = QDir(deployable.localFilePath)
            .entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
        if (files.isEmpty() /* && hasChangedSinceLastDeployment(deployable) */)
            m_d->filesToUpload << deployable;
        foreach (const QString &fileName, files) {
            const QString localFilePath = deployable.localFilePath
                + QLatin1Char('/') + fileName;
            const QString remoteDir = deployable.remoteDir + QLatin1Char('/')
                + fileInfo.fileName();
            checkDeploymentNeeded(DeployableFile(localFilePath, remoteDir));
        }
    } else  /* if (hasChangedSinceLastDeployment(deployable)) */ {
        m_d->filesToUpload << deployable;
    }
}

void GenericDirectUploadService::setFinished()
{
    m_d->stopRequested = false;
    m_d->state = Inactive;
    if (m_d->mkdirProc)
        disconnect(m_d->mkdirProc.data(), 0, this, 0);
    if (m_d->lnProc)
        disconnect(m_d->lnProc.data(), 0, this, 0);
    if (m_d->uploader) {
        disconnect(m_d->uploader.data(), 0, this, 0);
        m_d->uploader->closeChannel();
    }
}

void GenericDirectUploadService::uploadNextFile()
{
    if (m_d->filesToUpload.isEmpty()) {
        emit progressMessage(tr("All files successfully deployed."));
        setFinished();
        handleDeploymentDone();
        return;
    }

    const DeployableFile &d = m_d->filesToUpload.first();
    QString dirToCreate = d.remoteDir;
    QFileInfo fi(d.localFilePath);
    if (fi.isDir())
        dirToCreate += QLatin1Char('/') + fi.fileName();
    const QString command = QLatin1String("mkdir -vp ") + dirToCreate;
    m_d->mkdirProc = connection()->createRemoteProcess(command.toUtf8());
    connect(m_d->mkdirProc.data(), SIGNAL(closed(int)), SLOT(handleMkdirFinished(int)));
    connect(m_d->mkdirProc.data(), SIGNAL(outputAvailable(QByteArray)),
        SLOT(handleStdOutData(QByteArray)));
    connect(m_d->mkdirProc.data(), SIGNAL(errorOutputAvailable(QByteArray)),
        SLOT(handleStdErrData(QByteArray)));
    emit progressMessage(tr("Uploading file '%1'...")
        .arg(QDir::toNativeSeparators(d.localFilePath)));
    m_d->mkdirProc->start();
}

} //namespace RemoteLinux
<commit_msg>RemoteLinux: Get rid of non-standard mkdir option.<commit_after>/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
#include "genericdirectuploadservice.h"

#include "deployablefile.h"

#include <utils/qtcassert.h>
#include <utils/ssh/sftpchannel.h>
#include <utils/ssh/sshconnection.h>
#include <utils/ssh/sshremoteprocess.h>

#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QList>
#include <QtCore/QString>

using namespace Utils;

namespace RemoteLinux {
namespace Internal {
namespace {
enum State { Inactive, InitializingSftp, Uploading };
} // anonymous namespace

class GenericDirectUploadServicePrivate
{
public:
    GenericDirectUploadServicePrivate() : stopRequested(false), state(Inactive) {}

    bool stopRequested;
    State state;
    QList<DeployableFile> filesToUpload;
    SftpChannel::Ptr uploader;
    SshRemoteProcess::Ptr mkdirProc;
    SshRemoteProcess::Ptr lnProc;
    QList<DeployableFile> deployableFiles;
};

} // namespace Internal

using namespace Internal;

GenericDirectUploadService::GenericDirectUploadService(QObject *parent)
    : AbstractRemoteLinuxDeployService(parent), m_d(new GenericDirectUploadServicePrivate)
{
}

void GenericDirectUploadService::setDeployableFiles(const QList<DeployableFile> &deployableFiles)
{
    m_d->deployableFiles = deployableFiles;
}

bool GenericDirectUploadService::isDeploymentNecessary() const
{
    m_d->filesToUpload.clear();
    for (int i = 0; i < m_d->deployableFiles.count(); ++i)
        checkDeploymentNeeded(m_d->deployableFiles.at(i));
    return !m_d->filesToUpload.isEmpty();
}

void GenericDirectUploadService::doDeviceSetup()
{
    QTC_ASSERT(m_d->state == Inactive, return);

    handleDeviceSetupDone(true);
}

void GenericDirectUploadService::stopDeviceSetup()
{
    QTC_ASSERT(m_d->state == Inactive, return);

    handleDeviceSetupDone(false);
}

void GenericDirectUploadService::doDeploy()
{
    QTC_ASSERT(m_d->state == Inactive, setFinished(); return);

    m_d->uploader = connection()->createSftpChannel();
    connect(m_d->uploader.data(), SIGNAL(initialized()), SLOT(handleSftpInitialized()));
    connect(m_d->uploader.data(), SIGNAL(initializationFailed(QString)),
        SLOT(handleSftpInitializationFailed(QString)));
    m_d->uploader->initialize();
    m_d->state = InitializingSftp;
}

void GenericDirectUploadService::handleSftpInitialized()
{
    QTC_ASSERT(m_d->state == InitializingSftp, setFinished(); return);

    if (m_d->stopRequested) {
        setFinished();
        handleDeploymentDone();
        return;
    }

    Q_ASSERT(!m_d->filesToUpload.isEmpty());
    connect(m_d->uploader.data(), SIGNAL(finished(Utils::SftpJobId, QString)),
        SLOT(handleUploadFinished(Utils::SftpJobId,QString)));
    m_d->state = Uploading;
    uploadNextFile();
}

void GenericDirectUploadService::handleSftpInitializationFailed(const QString &message)
{
    QTC_ASSERT(m_d->state == InitializingSftp, setFinished(); return);

    emit errorMessage(tr("SFTP initialization failed: %1").arg(message));
    setFinished();
    handleDeploymentDone();
}

void GenericDirectUploadService::handleUploadFinished(Utils::SftpJobId jobId, const QString &errorMsg)
{
    Q_UNUSED(jobId);

    QTC_ASSERT(m_d->state == Uploading, setFinished(); return);

    if (m_d->stopRequested) {
        setFinished();
        handleDeploymentDone();
    }

    const DeployableFile d = m_d->filesToUpload.takeFirst();
    if (!errorMsg.isEmpty()) {
        emit errorMessage(tr("Upload of file '%1' failed: %2")
            .arg(QDir::toNativeSeparators(d.localFilePath), errorMsg));
        setFinished();
        handleDeploymentDone();
    } else {
        saveDeploymentTimeStamp(d);

        // Terrible hack for Windows.
        if (d.remoteDir.contains(QLatin1String("bin"))) {
            const QString remoteFilePath = d.remoteDir + QLatin1Char('/')
                + QFileInfo(d.localFilePath).fileName();
            const QString command = QLatin1String("chmod a+x ") + remoteFilePath;
            connection()->createRemoteProcess(command.toUtf8())->start();
        }

        uploadNextFile();
    }
}

void GenericDirectUploadService::handleLnFinished(int exitStatus)
{
    QTC_ASSERT(m_d->state == Uploading, setFinished(); return);

    if (m_d->stopRequested) {
        setFinished();
        handleDeploymentDone();
    }

    const DeployableFile d = m_d->filesToUpload.takeFirst();
    const QString nativePath = QDir::toNativeSeparators(d.localFilePath);
    if (exitStatus != SshRemoteProcess::ExitedNormally || m_d->lnProc->exitCode() != 0) {
        emit errorMessage(tr("Failed to upload file '%1'.").arg(nativePath));
        setFinished();
        handleDeploymentDone();
        return;
    } else {
        saveDeploymentTimeStamp(d);
        uploadNextFile();
    }
}

void GenericDirectUploadService::handleMkdirFinished(int exitStatus)
{
    QTC_ASSERT(m_d->state == Uploading, setFinished(); return);

    if (m_d->stopRequested) {
        setFinished();
        handleDeploymentDone();
    }

    const DeployableFile &d = m_d->filesToUpload.first();
    QFileInfo fi(d.localFilePath);
    const QString nativePath = QDir::toNativeSeparators(d.localFilePath);
    if (exitStatus != SshRemoteProcess::ExitedNormally || m_d->mkdirProc->exitCode() != 0) {
        emit errorMessage(tr("Failed to upload file '%1'.").arg(nativePath));
        setFinished();
        handleDeploymentDone();
    } else if (fi.isDir()) {
        saveDeploymentTimeStamp(d);
        m_d->filesToUpload.removeFirst();
        uploadNextFile();
    } else {
        const QString remoteFilePath = d.remoteDir + QLatin1Char('/')  + fi.fileName();
        if (fi.isSymLink()) {
             const QString target = fi.dir().relativeFilePath(fi.symLinkTarget()); // see QTBUG-5817.
             const QString command = QLatin1String("ln -vsf ") + target + QLatin1Char(' ')
                 + remoteFilePath;

             // See comment in SftpChannel::createLink as to why we can't use it.
             m_d->lnProc = connection()->createRemoteProcess(command.toUtf8());
             connect(m_d->lnProc.data(), SIGNAL(closed(int)), SLOT(handleLnFinished(int)));
             connect(m_d->lnProc.data(), SIGNAL(outputAvailable(QByteArray)),
                 SLOT(handleStdOutData(QByteArray)));
             connect(m_d->lnProc.data(), SIGNAL(errorOutputAvailable(QByteArray)),
                 SLOT(handleStdErrData(QByteArray)));
             m_d->lnProc->start();
        } else {
            const SftpJobId job = m_d->uploader->uploadFile(d.localFilePath, remoteFilePath,
                SftpOverwriteExisting);
            if (job == SftpInvalidJob) {
                emit errorMessage(tr("Failed to upload file '%1': "
                    "Could not open for reading.").arg(nativePath));
                setFinished();
                handleDeploymentDone();
            }
        }
    }
}

void GenericDirectUploadService::handleStdOutData(const QByteArray &data)
{
    emit stdOutData(QString::fromUtf8(data));
}

void GenericDirectUploadService::handleStdErrData(const QByteArray &data)
{
    emit stdErrData(QString::fromUtf8(data));
}

void GenericDirectUploadService::stopDeployment()
{
    QTC_ASSERT(m_d->state == InitializingSftp || m_d->state == Uploading, setFinished(); return);

    setFinished();
    handleDeploymentDone();
}

// Note: time stamp checks disabled for now; it's too much hassle for the user to force
// deployment in case the device has changed.
void GenericDirectUploadService::checkDeploymentNeeded(const DeployableFile &deployable) const
{
    QFileInfo fileInfo(deployable.localFilePath);
    if (fileInfo.isDir()) {
        const QStringList files = QDir(deployable.localFilePath)
            .entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
        if (files.isEmpty() /* && hasChangedSinceLastDeployment(deployable) */)
            m_d->filesToUpload << deployable;
        foreach (const QString &fileName, files) {
            const QString localFilePath = deployable.localFilePath
                + QLatin1Char('/') + fileName;
            const QString remoteDir = deployable.remoteDir + QLatin1Char('/')
                + fileInfo.fileName();
            checkDeploymentNeeded(DeployableFile(localFilePath, remoteDir));
        }
    } else  /* if (hasChangedSinceLastDeployment(deployable)) */ {
        m_d->filesToUpload << deployable;
    }
}

void GenericDirectUploadService::setFinished()
{
    m_d->stopRequested = false;
    m_d->state = Inactive;
    if (m_d->mkdirProc)
        disconnect(m_d->mkdirProc.data(), 0, this, 0);
    if (m_d->lnProc)
        disconnect(m_d->lnProc.data(), 0, this, 0);
    if (m_d->uploader) {
        disconnect(m_d->uploader.data(), 0, this, 0);
        m_d->uploader->closeChannel();
    }
}

void GenericDirectUploadService::uploadNextFile()
{
    if (m_d->filesToUpload.isEmpty()) {
        emit progressMessage(tr("All files successfully deployed."));
        setFinished();
        handleDeploymentDone();
        return;
    }

    const DeployableFile &d = m_d->filesToUpload.first();
    QString dirToCreate = d.remoteDir;
    QFileInfo fi(d.localFilePath);
    if (fi.isDir())
        dirToCreate += QLatin1Char('/') + fi.fileName();
    const QString command = QLatin1String("mkdir -p ") + dirToCreate;
    m_d->mkdirProc = connection()->createRemoteProcess(command.toUtf8());
    connect(m_d->mkdirProc.data(), SIGNAL(closed(int)), SLOT(handleMkdirFinished(int)));
    connect(m_d->mkdirProc.data(), SIGNAL(outputAvailable(QByteArray)),
        SLOT(handleStdOutData(QByteArray)));
    connect(m_d->mkdirProc.data(), SIGNAL(errorOutputAvailable(QByteArray)),
        SLOT(handleStdErrData(QByteArray)));
    emit progressMessage(tr("Uploading file '%1'...")
        .arg(QDir::toNativeSeparators(d.localFilePath)));
    m_d->mkdirProc->start();
}

} //namespace RemoteLinux
<|endoftext|>


<commit_before>//-----------------------------------------------------------------------bl-
//--------------------------------------------------------------------------
//
// GRINS - General Reacting Incompressible Navier-Stokes
//
// Copyright (C) 2014-2015 Paul T. Bauman, Roy H. Stogner
// Copyright (C) 2010-2013 The PECOS Development Team
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the Version 2.1 GNU Lesser General
// Public License as published by the Free Software Foundation.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc. 51 Franklin Street, Fifth Floor,
// Boston, MA  02110-1301  USA
//
//-----------------------------------------------------------------------el-

#include "grins_config.h"

#ifdef GRINS_HAVE_ANTIOCH

// This class
#include "grins/antioch_wilke_transport_evaluator.h"

// GRINS
#include "grins/cached_values.h"

namespace GRINS
{
  template<typename Thermo, typename Viscosity, typename Conductivity, typename Diffusivity>
  AntiochWilkeTransportEvaluator<Thermo,Viscosity,Conductivity,Diffusivity>::AntiochWilkeTransportEvaluator( const AntiochWilkeTransportMixture<Thermo,Viscosity,Conductivity,Diffusivity>& mixture )
    : AntiochEvaluator<Thermo>( mixture ),
    _wilke_evaluator( new Antioch::MixtureAveragedTransportEvaluator<Diffusivity,Viscosity,Conductivity,libMesh::Real>( mixture.wilke_mixture(), mixture.diffusivity(), mixture.viscosity(), mixture.conductivity() ) ),
    _diffusivity( mixture.diffusivity() )
  {
    return;
  }

  template<typename T, typename V, typename C, typename D>
  AntiochWilkeTransportEvaluator<T,V,C,D>::~AntiochWilkeTransportEvaluator()
  {
    return;
  }

  template<typename Th, typename V, typename C, typename D>
  libMesh::Real AntiochWilkeTransportEvaluator<Th,V,C,D>::mu( const CachedValues& cache, unsigned int qp )
  {
    const libMesh::Real T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
    const std::vector<libMesh::Real>& Y = cache.get_cached_vector_values(Cache::MASS_FRACTIONS)[qp];

    return this->mu( T, Y );
  }

  template<typename Th, typename V, typename C, typename D>
  libMesh::Real AntiochWilkeTransportEvaluator<Th,V,C,D>::k( const CachedValues& cache, unsigned int qp )
  {
    const libMesh::Real T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
    const std::vector<libMesh::Real>& Y = cache.get_cached_vector_values(Cache::MASS_FRACTIONS)[qp];

    return this->k( T, Y );
  }

  template<typename Th, typename V, typename C, typename D>
  void AntiochWilkeTransportEvaluator<Th,V,C,D>::mu_and_k( const CachedValues& cache, unsigned int qp,
                                                           libMesh::Real& mu, libMesh::Real& k )
  {
    const libMesh::Real T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
    const std::vector<libMesh::Real>& Y = cache.get_cached_vector_values(Cache::MASS_FRACTIONS)[qp];

    //_wilke_evaluator->mu_and_k( T, Y, mu, k );
    return;
  }

  template<typename Th, typename V, typename C, typename D>
  libMesh::Real AntiochWilkeTransportEvaluator<Th,V,C,D>::mu( const libMesh::Real T,
                                                              const std::vector<libMesh::Real>& Y )
  {
    return _wilke_evaluator->mu( T, Y );
  }

  template<typename Th, typename V, typename C, typename D>
  libMesh::Real AntiochWilkeTransportEvaluator<Th,V,C,D>::k( const libMesh::Real T,
                                                             const std::vector<libMesh::Real>& Y )
  {
    return 0.0;//_wilke_evaluator->k( T, Y );
  }

  template<typename Th, typename V, typename C, typename Diff>
  void AntiochWilkeTransportEvaluator<Th,V,C,Diff>::D( const libMesh::Real T,
                                                       const libMesh::Real rho,
                                                       const libMesh::Real cp,
                                                       const std::vector<libMesh::Real>& Y,
                                                       std::vector<libMesh::Real>& D )
  {
    libMesh::Real dummy = 0.0;
    _wilke_evaluator->mu_and_k_and_D( T, rho, cp, Y, dummy, dummy, D );
  }

  template<typename Th, typename V, typename C, typename Diff>
  void AntiochWilkeTransportEvaluator<Th,V,C,Diff>::mu_and_k_and_D( const libMesh::Real T,
                                                                    const libMesh::Real rho,
                                                                    const libMesh::Real cp,
                                                                    const std::vector<libMesh::Real>& Y,
                                                                    libMesh::Real& mu, libMesh::Real& k,
                                                                    std::vector<libMesh::Real>& D )
  {
    _wilke_evaluator->mu_and_k_and_D( T, rho, cp, Y, mu, k, D );
  }

} // end namespace GRINS

#endif // GRINS_HAVE_ANTIOCH
<commit_msg>Use correct mixtured averaged diffusion coefficient<commit_after>//-----------------------------------------------------------------------bl-
//--------------------------------------------------------------------------
//
// GRINS - General Reacting Incompressible Navier-Stokes
//
// Copyright (C) 2014-2015 Paul T. Bauman, Roy H. Stogner
// Copyright (C) 2010-2013 The PECOS Development Team
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the Version 2.1 GNU Lesser General
// Public License as published by the Free Software Foundation.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc. 51 Franklin Street, Fifth Floor,
// Boston, MA  02110-1301  USA
//
//-----------------------------------------------------------------------el-

#include "grins_config.h"

#ifdef GRINS_HAVE_ANTIOCH

// This class
#include "grins/antioch_wilke_transport_evaluator.h"

// GRINS
#include "grins/cached_values.h"

namespace GRINS
{
  template<typename Thermo, typename Viscosity, typename Conductivity, typename Diffusivity>
  AntiochWilkeTransportEvaluator<Thermo,Viscosity,Conductivity,Diffusivity>::AntiochWilkeTransportEvaluator( const AntiochWilkeTransportMixture<Thermo,Viscosity,Conductivity,Diffusivity>& mixture )
    : AntiochEvaluator<Thermo>( mixture ),
    _wilke_evaluator( new Antioch::MixtureAveragedTransportEvaluator<Diffusivity,Viscosity,Conductivity,libMesh::Real>( mixture.wilke_mixture(), mixture.diffusivity(), mixture.viscosity(), mixture.conductivity() ) ),
    _diffusivity( mixture.diffusivity() )
  {
    return;
  }

  template<typename T, typename V, typename C, typename D>
  AntiochWilkeTransportEvaluator<T,V,C,D>::~AntiochWilkeTransportEvaluator()
  {
    return;
  }

  template<typename Th, typename V, typename C, typename D>
  libMesh::Real AntiochWilkeTransportEvaluator<Th,V,C,D>::mu( const CachedValues& cache, unsigned int qp )
  {
    const libMesh::Real T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
    const std::vector<libMesh::Real>& Y = cache.get_cached_vector_values(Cache::MASS_FRACTIONS)[qp];

    return this->mu( T, Y );
  }

  template<typename Th, typename V, typename C, typename D>
  libMesh::Real AntiochWilkeTransportEvaluator<Th,V,C,D>::k( const CachedValues& cache, unsigned int qp )
  {
    const libMesh::Real T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
    const std::vector<libMesh::Real>& Y = cache.get_cached_vector_values(Cache::MASS_FRACTIONS)[qp];

    return this->k( T, Y );
  }

  template<typename Th, typename V, typename C, typename D>
  void AntiochWilkeTransportEvaluator<Th,V,C,D>::mu_and_k( const CachedValues& cache, unsigned int qp,
                                                           libMesh::Real& mu, libMesh::Real& k )
  {
    const libMesh::Real T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
    const std::vector<libMesh::Real>& Y = cache.get_cached_vector_values(Cache::MASS_FRACTIONS)[qp];

    //_wilke_evaluator->mu_and_k( T, Y, mu, k );
    return;
  }

  template<typename Th, typename V, typename C, typename D>
  libMesh::Real AntiochWilkeTransportEvaluator<Th,V,C,D>::mu( const libMesh::Real T,
                                                              const std::vector<libMesh::Real>& Y )
  {
    return _wilke_evaluator->mu( T, Y );
  }

  template<typename Th, typename V, typename C, typename D>
  libMesh::Real AntiochWilkeTransportEvaluator<Th,V,C,D>::k( const libMesh::Real T,
                                                             const std::vector<libMesh::Real>& Y )
  {
    return 0.0;//_wilke_evaluator->k( T, Y );
  }

  template<typename Th, typename V, typename C, typename Diff>
  void AntiochWilkeTransportEvaluator<Th,V,C,Diff>::D( const libMesh::Real T,
                                                       const libMesh::Real rho,
                                                       const libMesh::Real cp,
                                                       const std::vector<libMesh::Real>& Y,
                                                       std::vector<libMesh::Real>& D )
  {
    libMesh::Real dummy = 0.0;
    typename Antioch::MixtureAveragedTransportEvaluator<Diff,V,C,libMesh::Real>::DiffusivityType
      diff_type = Antioch::MixtureAveragedTransportEvaluator<Diff,V,C,libMesh::Real>::DiffusivityType::MASS_FLUX_MASS_FRACTION;

    _wilke_evaluator->mu_and_k_and_D( T, rho, cp, Y, dummy, dummy, D, diff_type);
  }

  template<typename Th, typename V, typename C, typename Diff>
  void AntiochWilkeTransportEvaluator<Th,V,C,Diff>::mu_and_k_and_D( const libMesh::Real T,
                                                                    const libMesh::Real rho,
                                                                    const libMesh::Real cp,
                                                                    const std::vector<libMesh::Real>& Y,
                                                                    libMesh::Real& mu, libMesh::Real& k,
                                                                    std::vector<libMesh::Real>& D )
  {
    typename Antioch::MixtureAveragedTransportEvaluator<Diff,V,C,libMesh::Real>::DiffusivityType
      diff_type = Antioch::MixtureAveragedTransportEvaluator<Diff,V,C,libMesh::Real>::DiffusivityType::MASS_FLUX_MASS_FRACTION;

    _wilke_evaluator->mu_and_k_and_D( T, rho, cp, Y, mu, k, D, diff_type );
  }

} // end namespace GRINS

#endif // GRINS_HAVE_ANTIOCH
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: XMLTextColumnsContext.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 12:57:33 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library 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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _XMLTEXTCOLUMNSCONTEXT_HXX
#define _XMLTEXTCOLUMNSCONTEXT_HXX

#ifndef _XMLOFF_XMLELEMENTPROPERTYCONTEXT_HXX
#include "XMLElementPropertyContext.hxx"
#endif

namespace rtl { class OUString; }
class XMLTextColumnsArray_Impl;
class XMLTextColumnSepContext_Impl;
class SvXMLTokenMap;

class XMLTextColumnsContext :public XMLElementPropertyContext
{
    const ::rtl::OUString sSeparatorLineIsOn;
    const ::rtl::OUString sSeparatorLineWidth;
    const ::rtl::OUString sSeparatorLineColor;
    const ::rtl::OUString sSeparatorLineRelativeHeight;
    const ::rtl::OUString sSeparatorLineVerticalAlignment;
    const ::rtl::OUString sIsAutomatic;
    const ::rtl::OUString sAutomaticDistance;

    XMLTextColumnsArray_Impl *pColumns;
    XMLTextColumnSepContext_Impl     *pColumnSep;
    SvXMLTokenMap            *pColumnAttrTokenMap;
    SvXMLTokenMap            *pColumnSepAttrTokenMap;
    sal_Int16                nCount;
    sal_Bool                 bAutomatic;
    sal_Int32                nAutomaticDistance;

public:
    TYPEINFO();

    XMLTextColumnsContext(
        SvXMLImport& rImport, sal_uInt16 nPrfx,
        const ::rtl::OUString& rLName,
        const ::com::sun::star::uno::Reference<
            ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
        const XMLPropertyState& rProp,
        ::std::vector< XMLPropertyState > &rProps );

    virtual ~XMLTextColumnsContext();

    virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
                                   const ::rtl::OUString& rLocalName,
                                   const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );

    virtual void EndElement();
};

#endif
<commit_msg>INTEGRATION: CWS changefileheader (1.4.448); FILE MERGED 2008/04/01 13:04:21 thb 1.4.448.2: #i85898# Stripping all external header guards 2008/03/31 16:27:54 rt 1.4.448.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: XMLTextColumnsContext.hxx,v $
 * $Revision: 1.5 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _XMLTEXTCOLUMNSCONTEXT_HXX
#define _XMLTEXTCOLUMNSCONTEXT_HXX

#include "XMLElementPropertyContext.hxx"

namespace rtl { class OUString; }
class XMLTextColumnsArray_Impl;
class XMLTextColumnSepContext_Impl;
class SvXMLTokenMap;

class XMLTextColumnsContext :public XMLElementPropertyContext
{
    const ::rtl::OUString sSeparatorLineIsOn;
    const ::rtl::OUString sSeparatorLineWidth;
    const ::rtl::OUString sSeparatorLineColor;
    const ::rtl::OUString sSeparatorLineRelativeHeight;
    const ::rtl::OUString sSeparatorLineVerticalAlignment;
    const ::rtl::OUString sIsAutomatic;
    const ::rtl::OUString sAutomaticDistance;

    XMLTextColumnsArray_Impl *pColumns;
    XMLTextColumnSepContext_Impl     *pColumnSep;
    SvXMLTokenMap            *pColumnAttrTokenMap;
    SvXMLTokenMap            *pColumnSepAttrTokenMap;
    sal_Int16                nCount;
    sal_Bool                 bAutomatic;
    sal_Int32                nAutomaticDistance;

public:
    TYPEINFO();

    XMLTextColumnsContext(
        SvXMLImport& rImport, sal_uInt16 nPrfx,
        const ::rtl::OUString& rLName,
        const ::com::sun::star::uno::Reference<
            ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
        const XMLPropertyState& rProp,
        ::std::vector< XMLPropertyState > &rProps );

    virtual ~XMLTextColumnsContext();

    virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
                                   const ::rtl::OUString& rLocalName,
                                   const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );

    virtual void EndElement();
};

#endif
<|endoftext|>


<commit_before>//  (C) Copyright Gennadiy Rozental 2001-2014.
//  Distributed under the Boost Software License, Version 1.0.
//  (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)

//  See http://www.boost.org/libs/test for the library home page.
//
/// @file
/// @brief Defines Unit Test Framework public API
// ***************************************************************************

#ifndef BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
#define BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER

// Boost.Test
#include <boost/test/framework.hpp>
#include <boost/test/tree/auto_registration.hpp>
#include <boost/test/tree/test_case_template.hpp>
#include <boost/test/tree/global_fixture.hpp>

#include <boost/test/detail/pp_variadic.hpp>

//____________________________________________________________________________//

// ************************************************************************** //
// **************    Non-auto (explicit) test case interface   ************** //
// ************************************************************************** //

#define BOOST_TEST_CASE( test_function )                                   \
boost::unit_test::make_test_case( boost::function<void ()>(test_function), \
                                  BOOST_TEST_STRINGIZE( test_function ),   \
                                  __FILE__, __LINE__ )
#define BOOST_CLASS_TEST_CASE( test_function, tc_instance )                \
boost::unit_test::make_test_case( (test_function),                         \
                                  BOOST_TEST_STRINGIZE( test_function ),   \
                                  __FILE__, __LINE__, tc_instance )

// ************************************************************************** //
// **************               BOOST_TEST_SUITE               ************** //
// ************************************************************************** //

#define BOOST_TEST_SUITE( testsuite_name ) \
( new boost::unit_test::test_suite( testsuite_name, __FILE__, __LINE__ ) )

// ************************************************************************** //
// **************             BOOST_AUTO_TEST_SUITE            ************** //
// ************************************************************************** //

#define BOOST_AUTO_TEST_SUITE_WITH_DECOR( suite_name, decorators )      \
namespace suite_name {                                                  \
BOOST_AUTO_TU_REGISTRAR( suite_name )(                                  \
    BOOST_STRINGIZE( suite_name ),                                      \
    __FILE__, __LINE__,                                                 \
    decorators );                                                       \
/**/

#define BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name )                    \
    BOOST_AUTO_TEST_SUITE_WITH_DECOR(                                   \
        suite_name,                                                     \
        boost::unit_test::decorator::collector::instance() )            \
/**/

#if BOOST_PP_VARIADICS
#define BOOST_AUTO_TEST_SUITE( ... )                                    \
    BOOST_TEST_INVOKE_IF_N_ARGS( 1,                                     \
        BOOST_AUTO_TEST_SUITE_NO_DECOR,                                 \
        BOOST_AUTO_TEST_SUITE_WITH_DECOR,                               \
        __VA_ARGS__)                                                    \
/**/

#else /* BOOST_PP_VARIADICS */

#define BOOST_AUTO_TEST_SUITE( suite_name )                             \
    BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name )                        \
/**/

#endif /* BOOST_PP_VARIADICS */

// ************************************************************************** //
// **************            BOOST_FIXTURE_TEST_SUITE          ************** //
// ************************************************************************** //

#define BOOST_FIXTURE_TEST_SUITE_WITH_DECOR(suite_name, F, decorators)  \
    BOOST_AUTO_TEST_SUITE_WITH_DECOR( suite_name, decorators )          \
typedef F BOOST_AUTO_TEST_CASE_FIXTURE;                                 \
/**/

#define BOOST_FIXTURE_TEST_SUITE_NO_DECOR( suite_name, F )              \
    BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name )                        \
typedef F BOOST_AUTO_TEST_CASE_FIXTURE;                                 \
/**/

#if BOOST_PP_VARIADICS

#define BOOST_FIXTURE_TEST_SUITE( ... )                                 \
    BOOST_TEST_INVOKE_IF_N_ARGS( 2,                                     \
        BOOST_FIXTURE_TEST_SUITE_NO_DECOR,                              \
        BOOST_FIXTURE_TEST_SUITE_WITH_DECOR,                            \
        __VA_ARGS__)                                                    \
/**/

#else /* BOOST_PP_VARIADICS */

#define BOOST_FIXTURE_TEST_SUITE( suite_name, F  )                      \
   BOOST_FIXTURE_TEST_SUITE_NO_DECOR( suite_name, F )                   \
/**/

#endif /* BOOST_PP_VARIADICS */

// ************************************************************************** //
// **************           BOOST_AUTO_TEST_SUITE_END          ************** //
// ************************************************************************** //

#define BOOST_AUTO_TEST_SUITE_END()                                     \
BOOST_AUTO_TU_REGISTRAR( BOOST_JOIN( end_suite, __LINE__ ) )( 1 );      \
}                                                                       \
/**/

// ************************************************************************** //
// **************    BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES    ************** //
// ************************************************************************** //

/// @deprecated use decorator instead
#define BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( test_name, n )          \
BOOST_TEST_DECORATOR( * boost::unit_test::expected_failures( n ) )      \
/**/

// ************************************************************************** //
// **************            BOOST_FIXTURE_TEST_CASE           ************** //
// ************************************************************************** //

#define BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, F, decorators )  \
struct test_name : public F { void test_method(); };                    \
                                                                        \
static void BOOST_AUTO_TC_INVOKER( test_name )()                        \
{                                                                       \
    BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture entry.");    \
    test_name t;                                                        \
    BOOST_TEST_CHECKPOINT('"' << #test_name << "\" entry.");            \
    t.test_method();                                                    \
    BOOST_TEST_CHECKPOINT('"' << #test_name << "\" exit.");             \
}                                                                       \
                                                                        \
struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {};                         \
                                                                        \
BOOST_AUTO_TU_REGISTRAR( test_name )(                                   \
    boost::unit_test::make_test_case(                                   \
        &BOOST_AUTO_TC_INVOKER( test_name ),                            \
        #test_name, __FILE__, __LINE__ ),                               \
        decorators );                                                   \
                                                                        \
void test_name::test_method()                                           \
/**/

#define BOOST_FIXTURE_TEST_CASE_NO_DECOR( test_name, F )                \
BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, F,                       \
    boost::unit_test::decorator::collector::instance() )                \
/**/

#if BOOST_PP_VARIADICS

#define BOOST_FIXTURE_TEST_CASE( ... )                                  \
    BOOST_TEST_INVOKE_IF_N_ARGS( 2,                                     \
        BOOST_FIXTURE_TEST_CASE_NO_DECOR,                               \
        BOOST_FIXTURE_TEST_CASE_WITH_DECOR,                             \
         __VA_ARGS__)                                                   \
/**/

#else /* BOOST_PP_VARIADICS */

#define BOOST_FIXTURE_TEST_CASE( test_name, F )                         \
     BOOST_FIXTURE_TEST_CASE_NO_DECOR(test_name, F)                     \
/**/

#endif /* BOOST_PP_VARIADICS */

// ************************************************************************** //
// **************             BOOST_AUTO_TEST_CASE             ************** //
// ************************************************************************** //

#define BOOST_AUTO_TEST_CASE_NO_DECOR( test_name )                      \
    BOOST_FIXTURE_TEST_CASE_NO_DECOR( test_name,                        \
        BOOST_AUTO_TEST_CASE_FIXTURE )                                  \
/**/

#define BOOST_AUTO_TEST_CASE_WITH_DECOR( test_name, decorators )        \
    BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name,                      \
        BOOST_AUTO_TEST_CASE_FIXTURE, decorators )                      \
/**/

#if BOOST_PP_VARIADICS

#define BOOST_AUTO_TEST_CASE( ... )                                     \
    BOOST_TEST_INVOKE_IF_N_ARGS( 1,                                     \
        BOOST_AUTO_TEST_CASE_NO_DECOR,                                  \
        BOOST_AUTO_TEST_CASE_WITH_DECOR,                                \
         __VA_ARGS__)                                                   \
/**/

#else /* BOOST_PP_VARIADICS */

#define BOOST_AUTO_TEST_CASE( test_name )                               \
    BOOST_AUTO_TEST_CASE_NO_DECOR( test_name )                          \
/**/

#endif /* BOOST_PP_VARIADICS */

// ************************************************************************** //
// **************       BOOST_FIXTURE_TEST_CASE_TEMPLATE       ************** //
// ************************************************************************** //

#define BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, F ) \
template<typename type_name>                                            \
struct test_name : public F                                             \
{ void test_method(); };                                                \
                                                                        \
struct BOOST_AUTO_TC_INVOKER( test_name ) {                             \
    template<typename TestType>                                         \
    static void run( boost::type<TestType>* = 0 )                       \
    {                                                                   \
        BOOST_TEST_CHECKPOINT('"' << #test_name <<"\" fixture entry."); \
        test_name<TestType> t;                                          \
        BOOST_TEST_CHECKPOINT('"' << #test_name << "\" entry.");        \
        t.test_method();                                                \
        BOOST_TEST_CHECKPOINT('"' << #test_name << "\" exit.");         \
    }                                                                   \
};                                                                      \
                                                                        \
BOOST_AUTO_TU_REGISTRAR( test_name )(                                   \
    boost::unit_test::ut_detail::template_test_case_gen<                \
        BOOST_AUTO_TC_INVOKER( test_name ),TL >(                        \
          BOOST_STRINGIZE( test_name ), __FILE__, __LINE__ ),           \
    boost::unit_test::decorator::collector::instance() );               \
                                                                        \
template<typename type_name>                                            \
void test_name<type_name>::test_method()                                \
/**/

// ************************************************************************** //
// **************        BOOST_AUTO_TEST_CASE_TEMPLATE         ************** //
// ************************************************************************** //

#define BOOST_AUTO_TEST_CASE_TEMPLATE( test_name, type_name, TL )       \
BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL,             \
    BOOST_AUTO_TEST_CASE_FIXTURE )                                      \
/**/

// ************************************************************************** //
// **************           BOOST_TEST_CASE_TEMPLATE           ************** //
// ************************************************************************** //

#define BOOST_TEST_CASE_TEMPLATE( name, typelist )                      \
    boost::unit_test::ut_detail::template_test_case_gen<name,typelist>( \
        BOOST_TEST_STRINGIZE( name ), __FILE__, __LINE__ )              \
/**/

// ************************************************************************** //
// **************      BOOST_TEST_CASE_TEMPLATE_FUNCTION       ************** //
// ************************************************************************** //

#define BOOST_TEST_CASE_TEMPLATE_FUNCTION( name, type_name )            \
template<typename type_name>                                            \
void BOOST_JOIN( name, _impl )( boost::type<type_name>* );              \
                                                                        \
struct name {                                                           \
    template<typename TestType>                                         \
    static void run( boost::type<TestType>* frwrd = 0 )                 \
    {                                                                   \
       BOOST_JOIN( name, _impl )( frwrd );                              \
    }                                                                   \
};                                                                      \
                                                                        \
template<typename type_name>                                            \
void BOOST_JOIN( name, _impl )( boost::type<type_name>* )               \
/**/

// ************************************************************************** //
// **************              BOOST_GLOBAL_FIXURE             ************** //
// ************************************************************************** //

#define BOOST_GLOBAL_FIXTURE( F ) \
static boost::unit_test::ut_detail::global_fixture_impl<F> BOOST_JOIN( gf_, F ) ; \
/**/

// ************************************************************************** //
// **************             BOOST_TEST_DECORATOR             ************** //
// ************************************************************************** //

#define BOOST_TEST_DECORATOR( D )                                       \
static boost::unit_test::decorator::collector const&                    \
BOOST_JOIN(decorator_collector,__LINE__) = D;                           \
/**/

// ************************************************************************** //
// **************         BOOST_AUTO_TEST_CASE_FIXTURE         ************** //
// ************************************************************************** //

namespace boost { namespace unit_test { namespace ut_detail {

struct nil_t {};

} // namespace ut_detail
} // unit_test
} // namespace boost

// Intentionally is in global namespace, so that FIXURE_TEST_SUITE can reset it in user code.
typedef ::boost::unit_test::ut_detail::nil_t BOOST_AUTO_TEST_CASE_FIXTURE;

// ************************************************************************** //
// **************   Auto registration facility helper macros   ************** //
// ************************************************************************** //

#define BOOST_AUTO_TU_REGISTRAR( test_name )                    \
static boost::unit_test::ut_detail::auto_test_unit_registrar    \
BOOST_JOIN( BOOST_JOIN( test_name, _registrar ), __LINE__ )     \
/**/
#define BOOST_AUTO_TC_INVOKER( test_name )      BOOST_JOIN( test_name, _invoker )
#define BOOST_AUTO_TC_UNIQUE_ID( test_name )    BOOST_JOIN( test_name, _id )

// ************************************************************************** //
// **************                BOOST_TEST_MAIN               ************** //
// ************************************************************************** //

#if defined(BOOST_TEST_MAIN)

#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
bool init_unit_test()                   {
#else
::boost::unit_test::test_suite*
init_unit_test_suite( int, char* [] )   {
#endif

#ifdef BOOST_TEST_MODULE
    using namespace ::boost::unit_test;
    assign_op( framework::master_test_suite().p_name.value, BOOST_TEST_STRINGIZE( BOOST_TEST_MODULE ).trim( "\"" ), 0 );

#endif

#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
    return true;
}
#else
    return 0;
}
#endif

#endif

//____________________________________________________________________________//

#endif // BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER

<commit_msg>semicolon should trail macro<commit_after>//  (C) Copyright Gennadiy Rozental 2001-2014.
//  Distributed under the Boost Software License, Version 1.0.
//  (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)

//  See http://www.boost.org/libs/test for the library home page.
//
/// @file
/// @brief Defines Unit Test Framework public API
// ***************************************************************************

#ifndef BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
#define BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER

// Boost.Test
#include <boost/test/framework.hpp>
#include <boost/test/tree/auto_registration.hpp>
#include <boost/test/tree/test_case_template.hpp>
#include <boost/test/tree/global_fixture.hpp>

#include <boost/test/detail/pp_variadic.hpp>

//____________________________________________________________________________//

// ************************************************************************** //
// **************    Non-auto (explicit) test case interface   ************** //
// ************************************************************************** //

#define BOOST_TEST_CASE( test_function )                                   \
boost::unit_test::make_test_case( boost::function<void ()>(test_function), \
                                  BOOST_TEST_STRINGIZE( test_function ),   \
                                  __FILE__, __LINE__ )
#define BOOST_CLASS_TEST_CASE( test_function, tc_instance )                \
boost::unit_test::make_test_case( (test_function),                         \
                                  BOOST_TEST_STRINGIZE( test_function ),   \
                                  __FILE__, __LINE__, tc_instance )

// ************************************************************************** //
// **************               BOOST_TEST_SUITE               ************** //
// ************************************************************************** //

#define BOOST_TEST_SUITE( testsuite_name ) \
( new boost::unit_test::test_suite( testsuite_name, __FILE__, __LINE__ ) )

// ************************************************************************** //
// **************             BOOST_AUTO_TEST_SUITE            ************** //
// ************************************************************************** //

#define BOOST_AUTO_TEST_SUITE_WITH_DECOR( suite_name, decorators )      \
namespace suite_name {                                                  \
BOOST_AUTO_TU_REGISTRAR( suite_name )(                                  \
    BOOST_STRINGIZE( suite_name ),                                      \
    __FILE__, __LINE__,                                                 \
    decorators );                                                       \
/**/

#define BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name )                    \
    BOOST_AUTO_TEST_SUITE_WITH_DECOR(                                   \
        suite_name,                                                     \
        boost::unit_test::decorator::collector::instance() )            \
/**/

#if BOOST_PP_VARIADICS
#define BOOST_AUTO_TEST_SUITE( ... )                                    \
    BOOST_TEST_INVOKE_IF_N_ARGS( 1,                                     \
        BOOST_AUTO_TEST_SUITE_NO_DECOR,                                 \
        BOOST_AUTO_TEST_SUITE_WITH_DECOR,                               \
        __VA_ARGS__)                                                    \
/**/

#else /* BOOST_PP_VARIADICS */

#define BOOST_AUTO_TEST_SUITE( suite_name )                             \
    BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name )                        \
/**/

#endif /* BOOST_PP_VARIADICS */

// ************************************************************************** //
// **************            BOOST_FIXTURE_TEST_SUITE          ************** //
// ************************************************************************** //

#define BOOST_FIXTURE_TEST_SUITE_WITH_DECOR(suite_name, F, decorators)  \
    BOOST_AUTO_TEST_SUITE_WITH_DECOR( suite_name, decorators )          \
typedef F BOOST_AUTO_TEST_CASE_FIXTURE;                                 \
/**/

#define BOOST_FIXTURE_TEST_SUITE_NO_DECOR( suite_name, F )              \
    BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name )                        \
typedef F BOOST_AUTO_TEST_CASE_FIXTURE;                                 \
/**/

#if BOOST_PP_VARIADICS

#define BOOST_FIXTURE_TEST_SUITE( ... )                                 \
    BOOST_TEST_INVOKE_IF_N_ARGS( 2,                                     \
        BOOST_FIXTURE_TEST_SUITE_NO_DECOR,                              \
        BOOST_FIXTURE_TEST_SUITE_WITH_DECOR,                            \
        __VA_ARGS__)                                                    \
/**/

#else /* BOOST_PP_VARIADICS */

#define BOOST_FIXTURE_TEST_SUITE( suite_name, F  )                      \
   BOOST_FIXTURE_TEST_SUITE_NO_DECOR( suite_name, F )                   \
/**/

#endif /* BOOST_PP_VARIADICS */

// ************************************************************************** //
// **************           BOOST_AUTO_TEST_SUITE_END          ************** //
// ************************************************************************** //

#define BOOST_AUTO_TEST_SUITE_END()                                     \
BOOST_AUTO_TU_REGISTRAR( BOOST_JOIN( end_suite, __LINE__ ) )( 1 );      \
}                                                                       \
/**/

// ************************************************************************** //
// **************    BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES    ************** //
// ************************************************************************** //

/// @deprecated use decorator instead
#define BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( test_name, n )          \
BOOST_TEST_DECORATOR( * boost::unit_test::expected_failures( n ) )      \
/**/

// ************************************************************************** //
// **************            BOOST_FIXTURE_TEST_CASE           ************** //
// ************************************************************************** //

#define BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, F, decorators )  \
struct test_name : public F { void test_method(); };                    \
                                                                        \
static void BOOST_AUTO_TC_INVOKER( test_name )()                        \
{                                                                       \
    BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture entry.");    \
    test_name t;                                                        \
    BOOST_TEST_CHECKPOINT('"' << #test_name << "\" entry.");            \
    t.test_method();                                                    \
    BOOST_TEST_CHECKPOINT('"' << #test_name << "\" exit.");             \
}                                                                       \
                                                                        \
struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {};                         \
                                                                        \
BOOST_AUTO_TU_REGISTRAR( test_name )(                                   \
    boost::unit_test::make_test_case(                                   \
        &BOOST_AUTO_TC_INVOKER( test_name ),                            \
        #test_name, __FILE__, __LINE__ ),                               \
        decorators );                                                   \
                                                                        \
void test_name::test_method()                                           \
/**/

#define BOOST_FIXTURE_TEST_CASE_NO_DECOR( test_name, F )                \
BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, F,                       \
    boost::unit_test::decorator::collector::instance() )                \
/**/

#if BOOST_PP_VARIADICS

#define BOOST_FIXTURE_TEST_CASE( ... )                                  \
    BOOST_TEST_INVOKE_IF_N_ARGS( 2,                                     \
        BOOST_FIXTURE_TEST_CASE_NO_DECOR,                               \
        BOOST_FIXTURE_TEST_CASE_WITH_DECOR,                             \
         __VA_ARGS__)                                                   \
/**/

#else /* BOOST_PP_VARIADICS */

#define BOOST_FIXTURE_TEST_CASE( test_name, F )                         \
     BOOST_FIXTURE_TEST_CASE_NO_DECOR(test_name, F)                     \
/**/

#endif /* BOOST_PP_VARIADICS */

// ************************************************************************** //
// **************             BOOST_AUTO_TEST_CASE             ************** //
// ************************************************************************** //

#define BOOST_AUTO_TEST_CASE_NO_DECOR( test_name )                      \
    BOOST_FIXTURE_TEST_CASE_NO_DECOR( test_name,                        \
        BOOST_AUTO_TEST_CASE_FIXTURE )                                  \
/**/

#define BOOST_AUTO_TEST_CASE_WITH_DECOR( test_name, decorators )        \
    BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name,                      \
        BOOST_AUTO_TEST_CASE_FIXTURE, decorators )                      \
/**/

#if BOOST_PP_VARIADICS

#define BOOST_AUTO_TEST_CASE( ... )                                     \
    BOOST_TEST_INVOKE_IF_N_ARGS( 1,                                     \
        BOOST_AUTO_TEST_CASE_NO_DECOR,                                  \
        BOOST_AUTO_TEST_CASE_WITH_DECOR,                                \
         __VA_ARGS__)                                                   \
/**/

#else /* BOOST_PP_VARIADICS */

#define BOOST_AUTO_TEST_CASE( test_name )                               \
    BOOST_AUTO_TEST_CASE_NO_DECOR( test_name )                          \
/**/

#endif /* BOOST_PP_VARIADICS */

// ************************************************************************** //
// **************       BOOST_FIXTURE_TEST_CASE_TEMPLATE       ************** //
// ************************************************************************** //

#define BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, F ) \
template<typename type_name>                                            \
struct test_name : public F                                             \
{ void test_method(); };                                                \
                                                                        \
struct BOOST_AUTO_TC_INVOKER( test_name ) {                             \
    template<typename TestType>                                         \
    static void run( boost::type<TestType>* = 0 )                       \
    {                                                                   \
        BOOST_TEST_CHECKPOINT('"' << #test_name <<"\" fixture entry."); \
        test_name<TestType> t;                                          \
        BOOST_TEST_CHECKPOINT('"' << #test_name << "\" entry.");        \
        t.test_method();                                                \
        BOOST_TEST_CHECKPOINT('"' << #test_name << "\" exit.");         \
    }                                                                   \
};                                                                      \
                                                                        \
BOOST_AUTO_TU_REGISTRAR( test_name )(                                   \
    boost::unit_test::ut_detail::template_test_case_gen<                \
        BOOST_AUTO_TC_INVOKER( test_name ),TL >(                        \
          BOOST_STRINGIZE( test_name ), __FILE__, __LINE__ ),           \
    boost::unit_test::decorator::collector::instance() );               \
                                                                        \
template<typename type_name>                                            \
void test_name<type_name>::test_method()                                \
/**/

// ************************************************************************** //
// **************        BOOST_AUTO_TEST_CASE_TEMPLATE         ************** //
// ************************************************************************** //

#define BOOST_AUTO_TEST_CASE_TEMPLATE( test_name, type_name, TL )       \
BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL,             \
    BOOST_AUTO_TEST_CASE_FIXTURE )                                      \
/**/

// ************************************************************************** //
// **************           BOOST_TEST_CASE_TEMPLATE           ************** //
// ************************************************************************** //

#define BOOST_TEST_CASE_TEMPLATE( name, typelist )                      \
    boost::unit_test::ut_detail::template_test_case_gen<name,typelist>( \
        BOOST_TEST_STRINGIZE( name ), __FILE__, __LINE__ )              \
/**/

// ************************************************************************** //
// **************      BOOST_TEST_CASE_TEMPLATE_FUNCTION       ************** //
// ************************************************************************** //

#define BOOST_TEST_CASE_TEMPLATE_FUNCTION( name, type_name )            \
template<typename type_name>                                            \
void BOOST_JOIN( name, _impl )( boost::type<type_name>* );              \
                                                                        \
struct name {                                                           \
    template<typename TestType>                                         \
    static void run( boost::type<TestType>* frwrd = 0 )                 \
    {                                                                   \
       BOOST_JOIN( name, _impl )( frwrd );                              \
    }                                                                   \
};                                                                      \
                                                                        \
template<typename type_name>                                            \
void BOOST_JOIN( name, _impl )( boost::type<type_name>* )               \
/**/

// ************************************************************************** //
// **************              BOOST_GLOBAL_FIXURE             ************** //
// ************************************************************************** //

#define BOOST_GLOBAL_FIXTURE( F ) \
static boost::unit_test::ut_detail::global_fixture_impl<F> BOOST_JOIN( gf_, F ) \
/**/

// ************************************************************************** //
// **************             BOOST_TEST_DECORATOR             ************** //
// ************************************************************************** //

#define BOOST_TEST_DECORATOR( D )                                       \
static boost::unit_test::decorator::collector const&                    \
BOOST_JOIN(decorator_collector,__LINE__) = D;                           \
/**/

// ************************************************************************** //
// **************         BOOST_AUTO_TEST_CASE_FIXTURE         ************** //
// ************************************************************************** //

namespace boost { namespace unit_test { namespace ut_detail {

struct nil_t {};

} // namespace ut_detail
} // unit_test
} // namespace boost

// Intentionally is in global namespace, so that FIXURE_TEST_SUITE can reset it in user code.
typedef ::boost::unit_test::ut_detail::nil_t BOOST_AUTO_TEST_CASE_FIXTURE;

// ************************************************************************** //
// **************   Auto registration facility helper macros   ************** //
// ************************************************************************** //

#define BOOST_AUTO_TU_REGISTRAR( test_name )                    \
static boost::unit_test::ut_detail::auto_test_unit_registrar    \
BOOST_JOIN( BOOST_JOIN( test_name, _registrar ), __LINE__ )     \
/**/
#define BOOST_AUTO_TC_INVOKER( test_name )      BOOST_JOIN( test_name, _invoker )
#define BOOST_AUTO_TC_UNIQUE_ID( test_name )    BOOST_JOIN( test_name, _id )

// ************************************************************************** //
// **************                BOOST_TEST_MAIN               ************** //
// ************************************************************************** //

#if defined(BOOST_TEST_MAIN)

#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
bool init_unit_test()                   {
#else
::boost::unit_test::test_suite*
init_unit_test_suite( int, char* [] )   {
#endif

#ifdef BOOST_TEST_MODULE
    using namespace ::boost::unit_test;
    assign_op( framework::master_test_suite().p_name.value, BOOST_TEST_STRINGIZE( BOOST_TEST_MODULE ).trim( "\"" ), 0 );

#endif

#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
    return true;
}
#else
    return 0;
}
#endif

#endif

//____________________________________________________________________________//

#endif // BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER

<|endoftext|>


<commit_before>/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

/*
 * XSEC
 *
 * TXFMOutputFile := Transform that outputs the byte stream to a file without changing
 *							  the actual data in any way
 *
 * $Id$
 *
 */

#include <xsec/transformers/TXFMOutputFile.hpp>
#include <xsec/framework/XSECException.hpp>

XERCES_CPP_NAMESPACE_USE

// Destructor

TXFMOutputFile::~TXFMOutputFile() {

    if (f.is_open())
        f.write("\n----- END -----\n", 17);
	f.close();

}

// Methods to set the inputs

void TXFMOutputFile::setInput(TXFMBase *newInput) {

	input = newInput;

	if (newInput->getOutputType() != TXFMBase::BYTE_STREAM) {

		throw XSECException(XSECException::TransformInputOutputFail, "OutputFile transform requires BYTE_STREAM input");

	}

	keepComments = input->getCommentsStatus();

}

bool TXFMOutputFile::setFile(char * const fileName) {

	// Open a file for outputting

	using std::ios;

    f.open(fileName, ios::binary|ios::out|ios::app);

	if (f.is_open()) {
        f.write("\n----- BEGIN -----\n", 19);
		return true;
    }

	return false;

}

// Methods to get tranform output type and input requirement

TXFMBase::ioType TXFMOutputFile::getInputType(void) {

	return TXFMBase::BYTE_STREAM;

}

TXFMBase::ioType TXFMOutputFile::getOutputType(void) {

	return TXFMBase::BYTE_STREAM;

}

TXFMBase::nodeType TXFMOutputFile::getNodeType(void) {

	return TXFMBase::DOM_NODE_NONE;

}

// Methods to get output data

unsigned int TXFMOutputFile::readBytes(XMLByte * const toFill, unsigned int maxToFill) {

	unsigned int sz;

	sz = input->readBytes(toFill, maxToFill);

	if (f.is_open())
		f.write((char *) toFill, sz);

	return sz;

}

DOMDocument * TXFMOutputFile::getDocument() {

	return NULL;

}

DOMNode * TXFMOutputFile::getFragmentNode() {

	return NULL;

};

const XMLCh * TXFMOutputFile::getFragmentId() {

	return NULL;	// Empty string

}
<commit_msg>SANTUARIO-449 - TXFMOutputFile can try to close unopened stream<commit_after>/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

/*
 * XSEC
 *
 * TXFMOutputFile := Transform that outputs the byte stream to a file without changing
 *							  the actual data in any way
 *
 * $Id$
 *
 */

#include <xsec/transformers/TXFMOutputFile.hpp>
#include <xsec/framework/XSECException.hpp>

XERCES_CPP_NAMESPACE_USE

// Destructor

TXFMOutputFile::~TXFMOutputFile() {

    if (f.is_open()) {
    	    f.write("\n----- END -----\n", 17);
    	    f.close();
    }
}

// Methods to set the inputs

void TXFMOutputFile::setInput(TXFMBase *newInput) {

	input = newInput;

	if (newInput->getOutputType() != TXFMBase::BYTE_STREAM) {

		throw XSECException(XSECException::TransformInputOutputFail, "OutputFile transform requires BYTE_STREAM input");

	}

	keepComments = input->getCommentsStatus();

}

bool TXFMOutputFile::setFile(char * const fileName) {

	// Open a file for outputting

	using std::ios;

    f.open(fileName, ios::binary|ios::out|ios::app);

	if (f.is_open()) {
        f.write("\n----- BEGIN -----\n", 19);
		return true;
    }

	return false;

}

// Methods to get tranform output type and input requirement

TXFMBase::ioType TXFMOutputFile::getInputType(void) {

	return TXFMBase::BYTE_STREAM;

}

TXFMBase::ioType TXFMOutputFile::getOutputType(void) {

	return TXFMBase::BYTE_STREAM;

}

TXFMBase::nodeType TXFMOutputFile::getNodeType(void) {

	return TXFMBase::DOM_NODE_NONE;

}

// Methods to get output data

unsigned int TXFMOutputFile::readBytes(XMLByte * const toFill, unsigned int maxToFill) {

	unsigned int sz;

	sz = input->readBytes(toFill, maxToFill);

	if (f.is_open())
		f.write((char *) toFill, sz);

	return sz;

}

DOMDocument * TXFMOutputFile::getDocument() {

	return NULL;

}

DOMNode * TXFMOutputFile::getFragmentNode() {

	return NULL;

};

const XMLCh * TXFMOutputFile::getFragmentId() {

	return NULL;	// Empty string

}
<|endoftext|>


<commit_before>/* g++ GotW1.cpp -omain -std=c++11 */

#include <iostream>

int main()
{

    int ival1 = 13;
    int ival2{14}; //C++11
    int ival3(15);
    int ival4;
    int ival5();

    std::cout << ival1 <<std::endl;
    std::cout << ival2 <<std::endl;
    std::cout << ival3 <<std::endl;
    std::cout << ival4 <<std::endl;
    std::cout << ival5 <<std::endl;

    return 0;
}

<commit_msg>Refactoring<commit_after>/* g++ GotW1.cpp -omain -std=c++11 */

#include <iostream>

int main()
{

    int ival1 = 13;
    int ival2{14}; // C++11
    int ival3(15);
    int ival4;
    int ival5(); // it's a function declaration

    std::cout << ival1 <<std::endl;
    std::cout << ival2 <<std::endl;
    std::cout << ival3 <<std::endl;
    std::cout << ival4 <<std::endl;
    std::cout << ival5 <<std::endl;

    return 0;
}

<|endoftext|>


<commit_before>#ifndef CRAB_DOMAIN_OPERATORS_API_HPP
#define CRAB_DOMAIN_OPERATORS_API_HPP

#include <crab/domains/numerical_domains_api.hpp>
#include <crab/domains/bitwise_operators_api.hpp>
#include <crab/domains/cast_operators_api.hpp>
#include <crab/domains/array_operators_api.hpp>
#include <crab/domains/pointer_operators_api.hpp>
#include <crab/domains/boolean_operators_api.hpp>

#include <crab/common/types.hpp>

namespace crab {

  namespace domains {

    /**
     * All abstract domains must inherit this class and expose
     * publicly all the public typedef's.
     **/
    template<typename N, typename V, typename Dom>
    class abstract_domain:
      public ikos::writeable,
      public ikos::numerical_domain<N,V>,
      public ikos::division_operators<N,V>,
      public backward_numerical_domain<N,V,Dom>,
      public ikos::bitwise_operators<N,V>,
      public int_cast_operators<V>,
      public array_operators<N,V>,
      public pointer_operators<N,V>,
      public boolean_operators<N,V> {

    public:

      typedef ikos::linear_expression<N,V> linear_expression_t;
      typedef ikos::linear_constraint<N,V> linear_constraint_t;
      typedef ikos::linear_constraint_system<N,V> linear_constraint_system_t;
      typedef ikos::variable<N,V> variable_t;
      typedef N number_t;
      typedef V varname_t;
      typedef std::vector<varname_t> varname_vector_t;

      abstract_domain (): ikos::writeable() {}
      virtual ~abstract_domain() {};

      // other operations
      virtual void rename(const varname_vector_t &from, const varname_vector_t &to) {
	CRAB_WARN("rename operation not implemented");
      }

      // TODO: move here all operations from domain_traits.hpp

    };

  }
}
#endif
<commit_msg>Added two more methods to abstract_domain api: - to_linear_constraint_system - to_disjunctive_linear_constraint_system<commit_after>#ifndef CRAB_DOMAIN_OPERATORS_API_HPP
#define CRAB_DOMAIN_OPERATORS_API_HPP

#include <crab/domains/numerical_domains_api.hpp>
#include <crab/domains/bitwise_operators_api.hpp>
#include <crab/domains/cast_operators_api.hpp>
#include <crab/domains/array_operators_api.hpp>
#include <crab/domains/pointer_operators_api.hpp>
#include <crab/domains/boolean_operators_api.hpp>

#include <crab/common/types.hpp>

namespace crab {

  namespace domains {

    /**
     * All abstract domains must inherit this class and expose
     * publicly all the public typedef's.
     **/
    template<typename N, typename V, typename Dom>
    class abstract_domain:
      public ikos::writeable,
      public ikos::numerical_domain<N,V>,
      public ikos::division_operators<N,V>,
      public backward_numerical_domain<N,V,Dom>,
      public ikos::bitwise_operators<N,V>,
      public int_cast_operators<V>,
      public array_operators<N,V>,
      public pointer_operators<N,V>,
      public boolean_operators<N,V> {

    public:

      typedef ikos::linear_expression<N,V> linear_expression_t;
      typedef ikos::linear_constraint<N,V> linear_constraint_t;
      typedef ikos::linear_constraint_system<N,V> linear_constraint_system_t;
      typedef ikos::disjunctive_linear_constraint_system<N,V>
      disjunctive_linear_constraint_system_t;
      typedef ikos::variable<N,V> variable_t;
      typedef N number_t;
      typedef V varname_t;
      typedef std::vector<varname_t> varname_vector_t;

      abstract_domain (): ikos::writeable() {}
      virtual ~abstract_domain() {};

      // other operations

      virtual linear_constraint_system_t to_linear_constraint_system() = 0;

      virtual disjunctive_linear_constraint_system_t
      to_disjunctive_linear_constraint_system () {
	CRAB_ERROR("to_disjunctive_linear_constraint_system operation not implemented");
      }

      virtual void rename(const varname_vector_t &from, const varname_vector_t &to) {
	CRAB_ERROR("rename operation not implemented");
      }

      // TODO: move here all operations from domain_traits.hpp

    };

  }
}
#endif
<|endoftext|>