<commit_before>/* KPilot
**
** Copyright (C) 1998-2001 by Dan Pilone
**
** This is a class that does "the work" of adding and deleting
** files in the pending_install directory of KPilot. It is used
** by the fileInstallWidget and by the daemon's drag-and-drop
** file accepter.
*/

/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA 02110-1301, USA.
*/

/*
** Bug reports and questions can be sent to kde-pim@kde.org
*/

#include "options.h"

#include <unistd.h>

#include <q3strlist.h>
#include <qdir.h>

#include <kglobal.h>
#include <kstandarddirs.h>
#include <kurl.h>
#include <kio/netaccess.h>
#include <kmessagebox.h>

#include "fileInstaller.moc"

FileInstaller::FileInstaller() :
	enabled(true)
{
	FUNCTIONSETUP;

	fDirName = KGlobal::dirs()->saveLocation("data",
		CSL1("kpilot/pending_install/"));
	fPendingCopies = 0;

}

/* virtual */ FileInstaller::~FileInstaller()
{
	FUNCTIONSETUP;
}

void FileInstaller::clearPending()
{
	FUNCTIONSETUP;

	unsigned int i;

	QDir installDir(fDirName);

	// Start from 2 to skip . and ..
	//
	for (i = 2; i < installDir.count(); i++)
	{
		QFile::remove(fDirName + installDir[i]);
	}

	if (i > 2)
	{
		emit filesChanged();
	}
}

void FileInstaller::deleteFile(const QString &file)
{
    QFile::remove(fDirName + file);
    emit filesChanged();
}

void FileInstaller::deleteFiles(const QStringList &files)
{
    if(files.empty())
        return;

    for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it)
        QFile::remove(fDirName + *it);

    emit filesChanged();
}

/* virtual */ bool FileInstaller::runCopy(const QString &s, QWidget *w )
{
	FUNCTIONSETUP;

	if(!(s.endsWith(CSL1(".pdb"), Qt::CaseInsensitive)
		|| s.endsWith(CSL1(".prc"), Qt::CaseInsensitive)))
	{
		KMessageBox::detailedSorry(w, i18n("Cannot install %1").arg(s),
			i18n("Only PalmOS database files (like *.pdb and *.prc) can be installed by the file installer."));
		return false;
	}

	DEBUGKPILOT << fname << ": Copying " << s << endl;

	KUrl src;
	KUrl dest;
	src.setPath(s);
	dest.setPath(fDirName + CSL1("/") + src.fileName());

	// Permissions -1, overwrite, no resume
	return KIO::NetAccess::file_copy(src, dest, -1, true, false, w);
}

void FileInstaller::addFiles(const QStringList & fileList, QWidget* w)
{
	FUNCTIONSETUP;

	if (!enabled) return;

	unsigned int succ = 0;

	for(QStringList::ConstIterator it = fileList.begin();
	    it != fileList.end(); ++it)
	{
		if (runCopy( *it, w ))
			succ++;
	}

	if (succ)
	{
		emit filesChanged();
	}
}

void FileInstaller::addFile( const QString & file, QWidget* w )
{
	FUNCTIONSETUP;

	if (!enabled) return;

	if (runCopy(file, w))
	{
		emit(filesChanged());
	}
}

/* slot */ void FileInstaller::copyCompleted()
{
	FUNCTIONSETUP;
}

const QStringList FileInstaller::fileNames() const
{
	FUNCTIONSETUP;

	QDir installDir(fDirName);

	return installDir.entryList(QDir::Files |
		QDir::NoSymLinks | QDir::Readable);
}

/* slot */ void FileInstaller::setEnabled(bool b)
{
	FUNCTIONSETUP;
	enabled=b;
}

<commit_msg>Other i18n fix<commit_after>/* KPilot
**
** Copyright (C) 1998-2001 by Dan Pilone
**
** This is a class that does "the work" of adding and deleting
** files in the pending_install directory of KPilot. It is used
** by the fileInstallWidget and by the daemon's drag-and-drop
** file accepter.
*/

/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA 02110-1301, USA.
*/

/*
** Bug reports and questions can be sent to kde-pim@kde.org
*/

#include "options.h"

#include <unistd.h>

#include <q3strlist.h>
#include <qdir.h>

#include <kglobal.h>
#include <kstandarddirs.h>
#include <kurl.h>
#include <kio/netaccess.h>
#include <kmessagebox.h>

#include "fileInstaller.moc"

FileInstaller::FileInstaller() :
	enabled(true)
{
	FUNCTIONSETUP;

	fDirName = KGlobal::dirs()->saveLocation("data",
		CSL1("kpilot/pending_install/"));
	fPendingCopies = 0;

}

/* virtual */ FileInstaller::~FileInstaller()
{
	FUNCTIONSETUP;
}

void FileInstaller::clearPending()
{
	FUNCTIONSETUP;

	unsigned int i;

	QDir installDir(fDirName);

	// Start from 2 to skip . and ..
	//
	for (i = 2; i < installDir.count(); i++)
	{
		QFile::remove(fDirName + installDir[i]);
	}

	if (i > 2)
	{
		emit filesChanged();
	}
}

void FileInstaller::deleteFile(const QString &file)
{
    QFile::remove(fDirName + file);
    emit filesChanged();
}

void FileInstaller::deleteFiles(const QStringList &files)
{
    if(files.empty())
        return;

    for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it)
        QFile::remove(fDirName + *it);

    emit filesChanged();
}

/* virtual */ bool FileInstaller::runCopy(const QString &s, QWidget *w )
{
	FUNCTIONSETUP;

	if(!(s.endsWith(CSL1(".pdb"), Qt::CaseInsensitive)
		|| s.endsWith(CSL1(".prc"), Qt::CaseInsensitive)))
	{
		KMessageBox::detailedSorry(w, i18n("Cannot install %1",s),
			i18n("Only PalmOS database files (like *.pdb and *.prc) can be installed by the file installer."));
		return false;
	}

	DEBUGKPILOT << fname << ": Copying " << s << endl;

	KUrl src;
	KUrl dest;
	src.setPath(s);
	dest.setPath(fDirName + CSL1("/") + src.fileName());

	// Permissions -1, overwrite, no resume
	return KIO::NetAccess::file_copy(src, dest, -1, true, false, w);
}

void FileInstaller::addFiles(const QStringList & fileList, QWidget* w)
{
	FUNCTIONSETUP;

	if (!enabled) return;

	unsigned int succ = 0;

	for(QStringList::ConstIterator it = fileList.begin();
	    it != fileList.end(); ++it)
	{
		if (runCopy( *it, w ))
			succ++;
	}

	if (succ)
	{
		emit filesChanged();
	}
}

void FileInstaller::addFile( const QString & file, QWidget* w )
{
	FUNCTIONSETUP;

	if (!enabled) return;

	if (runCopy(file, w))
	{
		emit(filesChanged());
	}
}

/* slot */ void FileInstaller::copyCompleted()
{
	FUNCTIONSETUP;
}

const QStringList FileInstaller::fileNames() const
{
	FUNCTIONSETUP;

	QDir installDir(fDirName);

	return installDir.entryList(QDir::Files |
		QDir::NoSymLinks | QDir::Readable);
}

/* slot */ void FileInstaller::setEnabled(bool b)
{
	FUNCTIONSETUP;
	enabled=b;
}

<|endoftext|>


<commit_before>// C++ source file - (C) 2003 Robert Osfield, released under the OSGPL.
//
// Simple example of use of Producer::RenderSurface + KeyboardMouseCallback + SimpleViewer
// example that provides the user with control over view position with basic picking.

#include <osg/Timer>
#include <osg/io_utils>
#include <osg/observer_ptr>

#include <osgUtil/IntersectionVisitor>
#include <osgUtil/PolytopeIntersector>
#include <osgUtil/LineSegmentIntersector>

#include <osgDB/ReadFile>
#include <osgDB/WriteFile>

#include <osgGA/TrackballManipulator>
#include <osgGA/StateSetManipulator>

#include <osgViewer/SimpleViewer>
#include <osgViewer/GraphicsWindow>

#include <osgFX/Scribe>

#include <iostream>

class CreateModelToSaveVisitor : public osg::NodeVisitor
{
public:

    CreateModelToSaveVisitor():
        osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
    {
        _group = new osg::Group;
        _addToModel = false;
    }

    virtual void apply(osg::Node& node)
    {
        osgFX::Scribe* scribe = dynamic_cast<osgFX::Scribe*>(&node);
        if (scribe)
        {
            for(unsigned int i=0; i<scribe->getNumChildren(); ++i)
            {
                _group->addChild(scribe->getChild(i));
            }
        }
        else
        {
            traverse(node);
        }
    }

    osg::ref_ptr<osg::Group> _group;
    bool _addToModel;
};

class ExitHandler : public osgGA::GUIEventHandler
{
public:

    ExitHandler():
        _done(false) {}

    bool done() const { return _done; }

    bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&)
    {
        switch(ea.getEventType())
        {
            case(osgGA::GUIEventAdapter::KEYUP):
            {
                if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Escape)
                {
                    _done = true;
                }
                return false;
            }
            case(osgGA::GUIEventAdapter::CLOSE_WINDOW):
            case(osgGA::GUIEventAdapter::QUIT_APPLICATION):
            {
                _done = true;
            }
            default: break;
        }

        return false;
    }

    bool _done;
};

// class to handle events with a pick
class PickHandler : public osgGA::GUIEventHandler
{
public:

    PickHandler():
        _mx(0.0),_my(0.0) {}

    ~PickHandler() {}

    bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
    {
        osgViewer::SimpleViewer* viewer = dynamic_cast<osgViewer::SimpleViewer*>(&aa);

        switch(ea.getEventType())
        {
            case(osgGA::GUIEventAdapter::KEYUP):
            {
                if (ea.getKey()=='s' && viewer)
                {
                    saveSelectedModel(viewer->getSceneData());
                }
                return false;
            }
            case(osgGA::GUIEventAdapter::PUSH):
            case(osgGA::GUIEventAdapter::MOVE):
            {
                _mx = ea.getX();
                _my = ea.getY();

                osg::notify(osg::NOTICE)<<"_mx="<<_mx<<" _my="<<_my<<std::endl;
                osg::notify(osg::NOTICE)<<"  range ="<<ea.getXmin()<<", "<<ea.getXmax()<<std::endl;

                return false;
            }
            case(osgGA::GUIEventAdapter::RELEASE):
            {
                if (_mx == ea.getX() && _my == ea.getY())
                {
                    // only do a pick if the mouse hasn't moved
                    pick(ea,viewer);
                }
                return true;
            }

            default:
                return false;
        }
    }

    void pick(const osgGA::GUIEventAdapter& ea, osgViewer::SimpleViewer* viewer)
    {
        osg::Node* scene = viewer->getSceneData();
        if (!scene) return;

        osg::notify(osg::NOTICE)<<std::endl;

        osg::Node* node = 0;
        osg::Group* parent = 0;

        bool usePolytopePicking = false;
        if (usePolytopePicking)
        {

#if 0
            // use window coordinates
            // remap the mouse x,y into viewport coordinates.
            osg::Viewport* viewport = viewer->getCamera()->getViewport();
            double mx = viewport->x() + (int)((double )viewport->width()*(ea.getXnormalized()*0.5+0.5));
            double my = viewport->y() + (int)((double )viewport->height()*(ea.getYnormalized()*0.5+0.5));

            // half width, height.
            double w = 5.0f;
            double h = 5.0f;
            osgUtil::PolytopeIntersector* picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW, mx-w, my-h, mx+w, my+h );
#else
            double mx = ea.getXnormalized();
            double my = ea.getYnormalized();
            double w = 0.05;
            double h = 0.05;
            osgUtil::PolytopeIntersector* picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::PROJECTION, mx-w, my-h, mx+w, my+h );
#endif
            osgUtil::IntersectionVisitor iv(picker);

            viewer->getCamera()->accept(iv);

            if (picker->containsIntersections())
            {
                osgUtil::PolytopeIntersector::Intersection intersection = picker->getFirstIntersection();

                osg::NodePath& nodePath = intersection.nodePath;
                node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
                parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0;

                if (node) std::cout<<"  Hits "<<node->className()<<" nodePath size"<<nodePath.size()<<std::endl;

            }

        }
        else
        {

            #if 0
            // use non dimensional coordinates - in projection/clip space
            osgUtil::LineSegmentIntersector* picker = new osgUtil::LineSegmentIntersector( osgUtil::Intersector::PROJECTION, ea.getXnormalized(),ea.getYnormalized() );
            #else
            // use window coordinates
            // remap the mouse x,y into viewport coordinates.
            osg::Viewport* viewport = viewer->getCamera()->getViewport();
            float mx = viewport->x() + (int)((float)viewport->width()*(ea.getXnormalized()*0.5f+0.5f));
            float my = viewport->y() + (int)((float)viewport->height()*(ea.getYnormalized()*0.5f+0.5f));
            osgUtil::LineSegmentIntersector* picker = new osgUtil::LineSegmentIntersector( osgUtil::Intersector::WINDOW, mx, my );
            #endif

            osgUtil::IntersectionVisitor iv(picker);

            viewer->getCamera()->accept(iv);

            if (picker->containsIntersections())
            {
                osgUtil::LineSegmentIntersector::Intersection intersection = picker->getFirstIntersection();
                osg::notify(osg::NOTICE)<<"Picked "<<intersection.localIntersectionPoint<<std::endl;

                osg::NodePath& nodePath = intersection.nodePath;
                node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
                parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0;

                if (node) std::cout<<"  Hits "<<node->className()<<" nodePath size"<<nodePath.size()<<std::endl;

            }
        }

        // now we try to decorate the hit node by the osgFX::Scribe to show that its been "picked"
        if (parent && node)
        {

            std::cout<<"  parent "<<parent->className()<<std::endl;

            osgFX::Scribe* parentAsScribe = dynamic_cast<osgFX::Scribe*>(parent);
            if (!parentAsScribe)
            {
                // node not already picked, so highlight it with an osgFX::Scribe
                osgFX::Scribe* scribe = new osgFX::Scribe();
                scribe->addChild(node);
                parent->replaceChild(node,scribe);
            }
            else
            {
                // node already picked so we want to remove scribe to unpick it.
                osg::Node::ParentList parentList = parentAsScribe->getParents();
                for(osg::Node::ParentList::iterator itr=parentList.begin();
                    itr!=parentList.end();
                    ++itr)
                {
                    (*itr)->replaceChild(parentAsScribe,node);
                }
            }
        }
    }

    void saveSelectedModel(osg::Node* scene)
    {
        if (!scene) return;

        CreateModelToSaveVisitor cmtsv;
        scene->accept(cmtsv);

        if (cmtsv._group->getNumChildren()>0)
        {
            std::cout<<"Writing selected compoents to 'selected_model.osg'"<<std::endl;
            osgDB::writeNodeFile(*cmtsv._group, "selected_model.osg");
        }
    }

protected:

    float _mx,_my;
};

int main( int argc, char **argv )
{
    if (argc<2)
    {
        std::cout << argv[0] <<": requires filename argument." << std::endl;
        return 1;
    }

    // load the scene.
    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(argv[1]);
    if (!loadedModel)
    {
        std::cout << argv[0] <<": No data loaded." << std::endl;
        return 1;
    }

    // create the window to draw to.
    osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
    traits->x = 200;
    traits->y = 200;
    traits->width = 800;
    traits->height = 600;
    traits->windowDecoration = true;
    traits->doubleBuffer = true;
    traits->sharedContext = 0;

    osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
    osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get());
    if (!gw)
    {
        osg::notify(osg::NOTICE)<<"Error: unable to create graphics window."<<std::endl;
        return 1;
    }

    gw->realize();
    gw->makeCurrent();

    // create the view of the scene.
    osgViewer::SimpleViewer viewer;
    viewer.setSceneData(loadedModel.get());

    viewer.setEventQueue(gw->getEventQueue());
    viewer.getEventQueue()->windowResize(traits->x,traits->y,traits->width,traits->height);

    // create a tracball manipulator to move the camera around in response to keyboard/mouse events
    viewer.setCameraManipulator( new osgGA::TrackballManipulator );

    osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator = new osgGA::StateSetManipulator;
    statesetManipulator->setStateSet(viewer.getSceneView()->getGlobalStateSet());
    viewer.addEventHandler(statesetManipulator.get());

    // add the pick handler
    viewer.addEventHandler(new PickHandler());

    // add the exit handler'
    ExitHandler* exitHandler = new ExitHandler;
    viewer.addEventHandler(exitHandler);

    viewer.init();

    // main loop (note, window toolkits which take control over the main loop will require a window redraw callback containing the code below.)
    while( gw->isRealized() && !exitHandler->done())
    {
        gw->checkEvents();

        viewer.frame();

        // Swap Buffers
        gw->swapBuffers();
    }

    return 0;
}

<commit_msg>Fixed comment<commit_after>// C++ source file - (C) 2003 Robert Osfield, released under the OSGPL.
//
// Simple example of use of osgViewer::GraphicsWindow + SimpleViewer
// example that provides the user with control over view position with basic picking.

#include <osg/Timer>
#include <osg/io_utils>
#include <osg/observer_ptr>

#include <osgUtil/IntersectionVisitor>
#include <osgUtil/PolytopeIntersector>
#include <osgUtil/LineSegmentIntersector>

#include <osgDB/ReadFile>
#include <osgDB/WriteFile>

#include <osgGA/TrackballManipulator>
#include <osgGA/StateSetManipulator>

#include <osgViewer/SimpleViewer>
#include <osgViewer/GraphicsWindow>

#include <osgFX/Scribe>

#include <iostream>

class CreateModelToSaveVisitor : public osg::NodeVisitor
{
public:

    CreateModelToSaveVisitor():
        osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
    {
        _group = new osg::Group;
        _addToModel = false;
    }

    virtual void apply(osg::Node& node)
    {
        osgFX::Scribe* scribe = dynamic_cast<osgFX::Scribe*>(&node);
        if (scribe)
        {
            for(unsigned int i=0; i<scribe->getNumChildren(); ++i)
            {
                _group->addChild(scribe->getChild(i));
            }
        }
        else
        {
            traverse(node);
        }
    }

    osg::ref_ptr<osg::Group> _group;
    bool _addToModel;
};

class ExitHandler : public osgGA::GUIEventHandler
{
public:

    ExitHandler():
        _done(false) {}

    bool done() const { return _done; }

    bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&)
    {
        switch(ea.getEventType())
        {
            case(osgGA::GUIEventAdapter::KEYUP):
            {
                if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Escape)
                {
                    _done = true;
                }
                return false;
            }
            case(osgGA::GUIEventAdapter::CLOSE_WINDOW):
            case(osgGA::GUIEventAdapter::QUIT_APPLICATION):
            {
                _done = true;
            }
            default: break;
        }

        return false;
    }

    bool _done;
};

// class to handle events with a pick
class PickHandler : public osgGA::GUIEventHandler
{
public:

    PickHandler():
        _mx(0.0),_my(0.0) {}

    ~PickHandler() {}

    bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
    {
        osgViewer::SimpleViewer* viewer = dynamic_cast<osgViewer::SimpleViewer*>(&aa);

        switch(ea.getEventType())
        {
            case(osgGA::GUIEventAdapter::KEYUP):
            {
                if (ea.getKey()=='s' && viewer)
                {
                    saveSelectedModel(viewer->getSceneData());
                }
                return false;
            }
            case(osgGA::GUIEventAdapter::PUSH):
            case(osgGA::GUIEventAdapter::MOVE):
            {
                _mx = ea.getX();
                _my = ea.getY();

                osg::notify(osg::NOTICE)<<"_mx="<<_mx<<" _my="<<_my<<std::endl;
                osg::notify(osg::NOTICE)<<"  range ="<<ea.getXmin()<<", "<<ea.getXmax()<<std::endl;

                return false;
            }
            case(osgGA::GUIEventAdapter::RELEASE):
            {
                if (_mx == ea.getX() && _my == ea.getY())
                {
                    // only do a pick if the mouse hasn't moved
                    pick(ea,viewer);
                }
                return true;
            }

            default:
                return false;
        }
    }

    void pick(const osgGA::GUIEventAdapter& ea, osgViewer::SimpleViewer* viewer)
    {
        osg::Node* scene = viewer->getSceneData();
        if (!scene) return;

        osg::notify(osg::NOTICE)<<std::endl;

        osg::Node* node = 0;
        osg::Group* parent = 0;

        bool usePolytopePicking = false;
        if (usePolytopePicking)
        {

#if 0
            // use window coordinates
            // remap the mouse x,y into viewport coordinates.
            osg::Viewport* viewport = viewer->getCamera()->getViewport();
            double mx = viewport->x() + (int)((double )viewport->width()*(ea.getXnormalized()*0.5+0.5));
            double my = viewport->y() + (int)((double )viewport->height()*(ea.getYnormalized()*0.5+0.5));

            // half width, height.
            double w = 5.0f;
            double h = 5.0f;
            osgUtil::PolytopeIntersector* picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW, mx-w, my-h, mx+w, my+h );
#else
            double mx = ea.getXnormalized();
            double my = ea.getYnormalized();
            double w = 0.05;
            double h = 0.05;
            osgUtil::PolytopeIntersector* picker = new osgUtil::PolytopeIntersector( osgUtil::Intersector::PROJECTION, mx-w, my-h, mx+w, my+h );
#endif
            osgUtil::IntersectionVisitor iv(picker);

            viewer->getCamera()->accept(iv);

            if (picker->containsIntersections())
            {
                osgUtil::PolytopeIntersector::Intersection intersection = picker->getFirstIntersection();

                osg::NodePath& nodePath = intersection.nodePath;
                node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
                parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0;

                if (node) std::cout<<"  Hits "<<node->className()<<" nodePath size"<<nodePath.size()<<std::endl;

            }

        }
        else
        {

            #if 0
            // use non dimensional coordinates - in projection/clip space
            osgUtil::LineSegmentIntersector* picker = new osgUtil::LineSegmentIntersector( osgUtil::Intersector::PROJECTION, ea.getXnormalized(),ea.getYnormalized() );
            #else
            // use window coordinates
            // remap the mouse x,y into viewport coordinates.
            osg::Viewport* viewport = viewer->getCamera()->getViewport();
            float mx = viewport->x() + (int)((float)viewport->width()*(ea.getXnormalized()*0.5f+0.5f));
            float my = viewport->y() + (int)((float)viewport->height()*(ea.getYnormalized()*0.5f+0.5f));
            osgUtil::LineSegmentIntersector* picker = new osgUtil::LineSegmentIntersector( osgUtil::Intersector::WINDOW, mx, my );
            #endif

            osgUtil::IntersectionVisitor iv(picker);

            viewer->getCamera()->accept(iv);

            if (picker->containsIntersections())
            {
                osgUtil::LineSegmentIntersector::Intersection intersection = picker->getFirstIntersection();
                osg::notify(osg::NOTICE)<<"Picked "<<intersection.localIntersectionPoint<<std::endl;

                osg::NodePath& nodePath = intersection.nodePath;
                node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
                parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0;

                if (node) std::cout<<"  Hits "<<node->className()<<" nodePath size"<<nodePath.size()<<std::endl;

            }
        }

        // now we try to decorate the hit node by the osgFX::Scribe to show that its been "picked"
        if (parent && node)
        {

            std::cout<<"  parent "<<parent->className()<<std::endl;

            osgFX::Scribe* parentAsScribe = dynamic_cast<osgFX::Scribe*>(parent);
            if (!parentAsScribe)
            {
                // node not already picked, so highlight it with an osgFX::Scribe
                osgFX::Scribe* scribe = new osgFX::Scribe();
                scribe->addChild(node);
                parent->replaceChild(node,scribe);
            }
            else
            {
                // node already picked so we want to remove scribe to unpick it.
                osg::Node::ParentList parentList = parentAsScribe->getParents();
                for(osg::Node::ParentList::iterator itr=parentList.begin();
                    itr!=parentList.end();
                    ++itr)
                {
                    (*itr)->replaceChild(parentAsScribe,node);
                }
            }
        }
    }

    void saveSelectedModel(osg::Node* scene)
    {
        if (!scene) return;

        CreateModelToSaveVisitor cmtsv;
        scene->accept(cmtsv);

        if (cmtsv._group->getNumChildren()>0)
        {
            std::cout<<"Writing selected compoents to 'selected_model.osg'"<<std::endl;
            osgDB::writeNodeFile(*cmtsv._group, "selected_model.osg");
        }
    }

protected:

    float _mx,_my;
};

int main( int argc, char **argv )
{
    if (argc<2)
    {
        std::cout << argv[0] <<": requires filename argument." << std::endl;
        return 1;
    }

    // load the scene.
    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(argv[1]);
    if (!loadedModel)
    {
        std::cout << argv[0] <<": No data loaded." << std::endl;
        return 1;
    }

    // create the window to draw to.
    osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
    traits->x = 200;
    traits->y = 200;
    traits->width = 800;
    traits->height = 600;
    traits->windowDecoration = true;
    traits->doubleBuffer = true;
    traits->sharedContext = 0;

    osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
    osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get());
    if (!gw)
    {
        osg::notify(osg::NOTICE)<<"Error: unable to create graphics window."<<std::endl;
        return 1;
    }

    gw->realize();
    gw->makeCurrent();

    // create the view of the scene.
    osgViewer::SimpleViewer viewer;
    viewer.setSceneData(loadedModel.get());

    viewer.setEventQueue(gw->getEventQueue());
    viewer.getEventQueue()->windowResize(traits->x,traits->y,traits->width,traits->height);

    // create a tracball manipulator to move the camera around in response to keyboard/mouse events
    viewer.setCameraManipulator( new osgGA::TrackballManipulator );

    osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator = new osgGA::StateSetManipulator;
    statesetManipulator->setStateSet(viewer.getSceneView()->getGlobalStateSet());
    viewer.addEventHandler(statesetManipulator.get());

    // add the pick handler
    viewer.addEventHandler(new PickHandler());

    // add the exit handler'
    ExitHandler* exitHandler = new ExitHandler;
    viewer.addEventHandler(exitHandler);

    viewer.init();

    // main loop (note, window toolkits which take control over the main loop will require a window redraw callback containing the code below.)
    while( gw->isRealized() && !exitHandler->done())
    {
        gw->checkEvents();

        viewer.frame();

        // Swap Buffers
        gw->swapBuffers();
    }

    return 0;
}

<|endoftext|>


<commit_before>#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TChain.h>
#include <TSystem.h>
#include "AliAnalysisManager.h"
#include "AliESDInputHandler.h"
#include "AliAODHandler.h"
#include "AliAnalysisTaskESDfilter.h"
#include "AliAnalysisDataContainer.h"
#endif

void CreateAODfromESD(const char *inFileName = "AliESDs.root",
		      const char *outFileName = "AliAODs.root") {

    gSystem->Load("libTree");
    gSystem->Load("libGeom");
    gSystem->Load("libPhysics");
    gSystem->Load("libVMC");
    gSystem->Load("libSTEERBase");
    gSystem->Load("libESD");
    gSystem->Load("libAOD");

    gSystem->Load("libANALYSIS");
    gSystem->Load("libANALYSISalice");
    gSystem->Load("libPWG3muon");

    TChain *chain = new TChain("esdTree");
    // Steering input chain
    chain->Add(inFileName);
    AliAnalysisManager *mgr  = new AliAnalysisManager("ESD to AOD", "Analysis Manager");

    // Input
    AliESDInputHandler* inpHandler = new AliESDInputHandler();
    inpHandler->SetReadTags();
    mgr->SetInputEventHandler  (inpHandler);

    // Output
    AliAODHandler* aodHandler   = new AliAODHandler();
    aodHandler->SetOutputFileName(outFileName);
    mgr->SetOutputEventHandler(aodHandler);

    // Task
    // Barrel Tracks
    AliAnalysisTaskESDfilter *filter = new AliAnalysisTaskESDfilter("Filter");
    mgr->AddTask(filter);
    // Muons
    AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
    mgr->AddTask(esdmuonfilter);

    // Cuts on primary tracks
    AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Standard");
    esdTrackCutsL->SetMinNClustersTPC(50);
    esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
    esdTrackCutsL->SetMaxCovDiagonalElements(2, 2, 0.5, 0.5, 2);
    esdTrackCutsL->SetRequireTPCRefit(kTRUE);
    esdTrackCutsL->SetMaxDCAToVertexXY(3.0);
    esdTrackCutsL->SetMaxDCAToVertexZ(3.0);
    esdTrackCutsL->SetDCAToVertex2D(kTRUE);
    esdTrackCutsL->SetRequireSigmaToVertex(kFALSE);
    esdTrackCutsL->SetAcceptKingDaughters(kFALSE);

    AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
    trackFilter->AddCuts(esdTrackCutsL);

    // Cuts on V0s
    AliESDv0Cuts*   esdV0Cuts = new AliESDv0Cuts("AliESDv0Cuts", "Standard pp");
    esdV0Cuts->SetMinRadius(0.2);
    esdV0Cuts->SetMaxRadius(100);
    esdV0Cuts->SetMinDcaPosToVertex(0.05);
    esdV0Cuts->SetMinDcaNegToVertex(0.05);
    esdV0Cuts->SetMaxDcaV0Daughters(0.5);
    esdV0Cuts->SetMinCosinePointingAngle(0.99);
    AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
    v0Filter->AddCuts(esdV0Cuts);

//
    filter->SetTrackFilter(trackFilter);
    filter->SetV0Filter(v0Filter);

//  Create AOD Tags
    AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator");
    mgr->AddTask(tagTask);

    // Pipelining
    AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
    AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer();
    AliAnalysisDataContainer *coutputT
	= mgr->CreateContainer("cTag",  TTree::Class(), AliAnalysisManager::kOutputContainer, "AOD.tag.root");

    mgr->ConnectInput (filter, 0, cinput1 );
    mgr->ConnectOutput(filter, 0, coutput1);

    mgr->ConnectInput (esdmuonfilter, 0, cinput1 );
//    mgr->ConnectOutput(esdmuonfilter, 0, coutput1);

    mgr->ConnectInput (tagTask, 0, cinput1);
    mgr->ConnectOutput(tagTask, 1, coutputT);

    //
    // Run the analysis
    //
    mgr->InitAnalysis();
    mgr->PrintStatus();
    mgr->StartAnalysis("local", chain);
}
<commit_msg>ITS stand-alone tracks added to AOD (A. Dainese)<commit_after>#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TChain.h>
#include <TSystem.h>
#include "AliAnalysisManager.h"
#include "AliESDInputHandler.h"
#include "AliAODHandler.h"
#include "AliAnalysisTaskESDfilter.h"
#include "AliAnalysisDataContainer.h"
#endif

void CreateAODfromESD(const char *inFileName = "AliESDs.root",
		      const char *outFileName = "AliAODs.root") {

    gSystem->Load("libTree");
    gSystem->Load("libGeom");
    gSystem->Load("libPhysics");
    gSystem->Load("libVMC");
    gSystem->Load("libSTEERBase");
    gSystem->Load("libESD");
    gSystem->Load("libAOD");

    gSystem->Load("libANALYSIS");
    gSystem->Load("libANALYSISalice");
    gSystem->Load("libPWG3muon");

    TChain *chain = new TChain("esdTree");
    // Steering input chain
    chain->Add(inFileName);
    AliAnalysisManager *mgr  = new AliAnalysisManager("ESD to AOD", "Analysis Manager");

    // Input
    AliESDInputHandler* inpHandler = new AliESDInputHandler();
    inpHandler->SetReadTags();
    mgr->SetInputEventHandler  (inpHandler);

    // Output
    AliAODHandler* aodHandler   = new AliAODHandler();
    aodHandler->SetOutputFileName(outFileName);
    mgr->SetOutputEventHandler(aodHandler);

    // Task
    // Barrel Tracks
    AliAnalysisTaskESDfilter *filter = new AliAnalysisTaskESDfilter("Filter");
    mgr->AddTask(filter);
    // Muons
    AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
    mgr->AddTask(esdmuonfilter);

    // Cuts on primary tracks
    AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Standard");
    esdTrackCutsL->SetMinNClustersTPC(50);
    esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
    esdTrackCutsL->SetMaxCovDiagonalElements(2, 2, 0.5, 0.5, 2);
    esdTrackCutsL->SetRequireTPCRefit(kTRUE);
    esdTrackCutsL->SetMaxDCAToVertexXY(3.0);
    esdTrackCutsL->SetMaxDCAToVertexZ(3.0);
    esdTrackCutsL->SetDCAToVertex2D(kTRUE);
    esdTrackCutsL->SetRequireSigmaToVertex(kFALSE);
    esdTrackCutsL->SetAcceptKingDaughters(kFALSE);
    // ITS stand-alone tracks
    AliESDtrackCuts* esdTrackCutsITSsa = new AliESDtrackCuts("AliESDtrackCuts", "ITS stand-alone");
    esdTrackCutsITSsa->SetRequireITSStandAlone(kTRUE);

    AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
    trackFilter->AddCuts(esdTrackCutsL);
    trackFilter->AddCuts(esdTrackCutsITSsa);

    // Cuts on V0s
    AliESDv0Cuts*   esdV0Cuts = new AliESDv0Cuts("AliESDv0Cuts", "Standard pp");
    esdV0Cuts->SetMinRadius(0.2);
    esdV0Cuts->SetMaxRadius(100);
    esdV0Cuts->SetMinDcaPosToVertex(0.05);
    esdV0Cuts->SetMinDcaNegToVertex(0.05);
    esdV0Cuts->SetMaxDcaV0Daughters(0.5);
    esdV0Cuts->SetMinCosinePointingAngle(0.99);
    AliAnalysisFilter* v0Filter = new AliAnalysisFilter("v0Filter");
    v0Filter->AddCuts(esdV0Cuts);

//
    filter->SetTrackFilter(trackFilter);
    filter->SetV0Filter(v0Filter);

//  Create AOD Tags
    AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator");
    mgr->AddTask(tagTask);

    // Pipelining
    AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
    AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer();
    AliAnalysisDataContainer *coutputT
	= mgr->CreateContainer("cTag",  TTree::Class(), AliAnalysisManager::kOutputContainer, "AOD.tag.root");

    mgr->ConnectInput (filter, 0, cinput1 );
    mgr->ConnectOutput(filter, 0, coutput1);

    mgr->ConnectInput (esdmuonfilter, 0, cinput1 );
//    mgr->ConnectOutput(esdmuonfilter, 0, coutput1);

    mgr->ConnectInput (tagTask, 0, cinput1);
    mgr->ConnectOutput(tagTask, 1, coutputT);

    //
    // Run the analysis
    //
    mgr->InitAnalysis();
    mgr->PrintStatus();
    mgr->StartAnalysis("local", chain);
}

<|endoftext|>


<commit_before>//   Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved.
//
//   Redistribution and use in source and binary forms, with or without modifica-
//   tion, are permitted provided that the following conditions are met:
//
//   1. Redistributions of  source code must  retain the above copyright  notice,
//      this list of conditions and the following disclaimer.
//
//   2. Redistributions in binary form must reproduce the above copyright notice,
//      this list of conditions and the following disclaimer in the documentation
//      and/or other materials provided with the distribution.
//
//   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
//   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
//   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
//   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
//   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
//   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
//   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
//   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
//   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
//   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <log4cplus/config.hxx>
#ifndef LOG4CPLUS_SINGLE_THREADED

#include <log4cplus/helpers/queue.h>
#include <log4cplus/helpers/loglog.h>
#include <log4cplus/thread/syncprims-pub-impl.h>
#include <stdexcept>
#include <algorithm>
#include <iterator>

namespace log4cplus { namespace thread {

Queue::Queue (unsigned len)
    : ev_consumer (false)
    , sem (len, len)
    , flags (DRAIN)
{ }

Queue::~Queue ()
{ }

Queue::flags_type
Queue::put_event (spi::InternalLoggingEvent const & ev)
{
    flags_type ret_flags = ERROR_BIT;
    try
    {
        ev.gatherThreadSpecificData ();

        SemaphoreGuard semguard (sem);
        MutexGuard mguard (mutex);

        ret_flags |= flags;

        if (flags & EXIT)
        {
            ret_flags &= ~(ERROR_BIT | ERROR_AFTER);
            return ret_flags;
        }
        else
        {
            queue.push_front (ev);
            ret_flags |= ERROR_AFTER;
            semguard.detach ();
            flags |= QUEUE;
            ret_flags |= flags;
            mguard.unlock ();
            mguard.detach ();
            ev_consumer.signal ();
        }
    }
    catch (std::runtime_error const & e)
    {
        (void)e;
        return ret_flags;
    }

    ret_flags &= ~(ERROR_BIT | ERROR_AFTER);
    return ret_flags;
}

Queue::flags_type
Queue::signal_exit (bool drain)
{
    flags_type ret_flags = 0;

    try
    {
        MutexGuard mguard (mutex);

        ret_flags |= flags;

        if (! (flags & EXIT))
        {
            if (drain)
                flags |= DRAIN;
            else
                flags &= ~DRAIN;
            flags |= EXIT;
            ret_flags = flags;
            mguard.unlock ();
            mguard.detach ();
            ev_consumer.signal ();
        }
    }
    catch (std::runtime_error const & e)
    {
        (void)e;
        ret_flags |= ERROR_BIT;
        return ret_flags;
    }

    return ret_flags;
}

Queue::flags_type
Queue::get_events (spi::InternalLoggingEvent * buf, std::size_t buf_size,
    std::size_t * pulled)
{
    flags_type ret_flags = 0;

    try
    {
        while (true)
        {
            MutexGuard mguard (mutex);

            ret_flags = flags;

            if (((QUEUE & flags) && ! (EXIT & flags))
                || ((EXIT | DRAIN | QUEUE) & flags) == (EXIT | DRAIN | QUEUE))
            {
                assert (! queue.empty ());

                std::size_t const pull_count = (std::min) (queue.size (), buf_size);

                queue_storage_type::reverse_iterator qit = queue.rbegin ();
                spi::InternalLoggingEvent * bufit = buf;
                spi::InternalLoggingEvent const * const buf_end = buf + pull_count;
                for (; bufit != buf_end; ++qit, ++bufit)
                {
                    bufit->swap (*qit);
                }

                assert (std::distance (qit.base (), queue.end ())
                    == static_cast<queue_storage_type::difference_type>(pull_count));
                queue.erase (qit.base (), queue.end ());
                *pulled = pull_count;

                if (queue.empty ())
                    flags &= ~QUEUE;
                sem.unlock ();
                ret_flags = flags | EVENT;
                break;
            }
            else if (((EXIT | QUEUE) & flags) == (EXIT | QUEUE))
            {
                assert (! queue.empty ());
                queue.clear ();
                flags &= ~QUEUE;
                ev_consumer.reset ();
                sem.unlock ();
                ret_flags = flags;
                break;
            }
            else if (EXIT & flags)
                break;
            else
            {
                ev_consumer.reset ();
                mguard.unlock ();
                mguard.detach ();
                ev_consumer.wait ();
            }
        }
    }
    catch (std::runtime_error const & e)
    {
        (void)e;
        ret_flags |= ERROR_BIT;
    }

    return ret_flags;
}

} } // namespace log4cplus { namespace thread {

#endif // LOG4CPLUS_SINGLE_THREADED
<commit_msg>queue.cxx: Make the queue protecting mutex non-recursive.<commit_after>//   Copyright (C) 2009-2010, Vaclav Haisman. All rights reserved.
//
//   Redistribution and use in source and binary forms, with or without modifica-
//   tion, are permitted provided that the following conditions are met:
//
//   1. Redistributions of  source code must  retain the above copyright  notice,
//      this list of conditions and the following disclaimer.
//
//   2. Redistributions in binary form must reproduce the above copyright notice,
//      this list of conditions and the following disclaimer in the documentation
//      and/or other materials provided with the distribution.
//
//   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
//   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
//   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
//   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
//   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
//   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
//   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
//   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
//   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
//   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <log4cplus/config.hxx>
#ifndef LOG4CPLUS_SINGLE_THREADED

#include <log4cplus/helpers/queue.h>
#include <log4cplus/helpers/loglog.h>
#include <log4cplus/thread/syncprims-pub-impl.h>
#include <stdexcept>
#include <algorithm>
#include <iterator>

namespace log4cplus { namespace thread {

Queue::Queue (unsigned len)
    : mutex (Mutex::DEFAULT)
    , ev_consumer (false)
    , sem (len, len)
    , flags (DRAIN)
{ }

Queue::~Queue ()
{ }

Queue::flags_type
Queue::put_event (spi::InternalLoggingEvent const & ev)
{
    flags_type ret_flags = ERROR_BIT;
    try
    {
        ev.gatherThreadSpecificData ();

        SemaphoreGuard semguard (sem);
        MutexGuard mguard (mutex);

        ret_flags |= flags;

        if (flags & EXIT)
        {
            ret_flags &= ~(ERROR_BIT | ERROR_AFTER);
            return ret_flags;
        }
        else
        {
            queue.push_front (ev);
            ret_flags |= ERROR_AFTER;
            semguard.detach ();
            flags |= QUEUE;
            ret_flags |= flags;
            mguard.unlock ();
            mguard.detach ();
            ev_consumer.signal ();
        }
    }
    catch (std::runtime_error const & e)
    {
        (void)e;
        return ret_flags;
    }

    ret_flags &= ~(ERROR_BIT | ERROR_AFTER);
    return ret_flags;
}

Queue::flags_type
Queue::signal_exit (bool drain)
{
    flags_type ret_flags = 0;

    try
    {
        MutexGuard mguard (mutex);

        ret_flags |= flags;

        if (! (flags & EXIT))
        {
            if (drain)
                flags |= DRAIN;
            else
                flags &= ~DRAIN;
            flags |= EXIT;
            ret_flags = flags;
            mguard.unlock ();
            mguard.detach ();
            ev_consumer.signal ();
        }
    }
    catch (std::runtime_error const & e)
    {
        (void)e;
        ret_flags |= ERROR_BIT;
        return ret_flags;
    }

    return ret_flags;
}

Queue::flags_type
Queue::get_events (spi::InternalLoggingEvent * buf, std::size_t buf_size,
    std::size_t * pulled)
{
    flags_type ret_flags = 0;

    try
    {
        while (true)
        {
            MutexGuard mguard (mutex);

            ret_flags = flags;

            if (((QUEUE & flags) && ! (EXIT & flags))
                || ((EXIT | DRAIN | QUEUE) & flags) == (EXIT | DRAIN | QUEUE))
            {
                assert (! queue.empty ());

                std::size_t const pull_count = (std::min) (queue.size (), buf_size);

                queue_storage_type::reverse_iterator qit = queue.rbegin ();
                spi::InternalLoggingEvent * bufit = buf;
                spi::InternalLoggingEvent const * const buf_end = buf + pull_count;
                for (; bufit != buf_end; ++qit, ++bufit)
                {
                    bufit->swap (*qit);
                }

                assert (std::distance (qit.base (), queue.end ())
                    == static_cast<queue_storage_type::difference_type>(pull_count));
                queue.erase (qit.base (), queue.end ());
                *pulled = pull_count;

                if (queue.empty ())
                    flags &= ~QUEUE;
                sem.unlock ();
                ret_flags = flags | EVENT;
                break;
            }
            else if (((EXIT | QUEUE) & flags) == (EXIT | QUEUE))
            {
                assert (! queue.empty ());
                queue.clear ();
                flags &= ~QUEUE;
                ev_consumer.reset ();
                sem.unlock ();
                ret_flags = flags;
                break;
            }
            else if (EXIT & flags)
                break;
            else
            {
                ev_consumer.reset ();
                mguard.unlock ();
                mguard.detach ();
                ev_consumer.wait ();
            }
        }
    }
    catch (std::runtime_error const & e)
    {
        (void)e;
        ret_flags |= ERROR_BIT;
    }

    return ret_flags;
}

} } // namespace log4cplus { namespace thread {

#endif // LOG4CPLUS_SINGLE_THREADED
<|endoftext|>


<commit_before>/**
 * @file clusterProxyHelper.cc
 * @author Rafal Slota
 * @copyright (C) 2013 ACK CYFRONET AGH
 * @copyright This software is released under the MIT license cited in 'LICENSE.txt'
 */

#include "clusterProxyHelper.h"

#include "communication/communicator.h"
#include "communication/exception.h"
#include "logging.h"
#include "remote_file_management.pb.h"

#include <boost/algorithm/string/case_conv.hpp>
#include <boost/any.hpp>

#include <functional>

using namespace std;
using namespace std::placeholders;
using namespace one::clproto::remote_file_management;
using namespace one::clproto::communication_protocol;

namespace one {
namespace helpers {

std::unique_ptr<RemoteFileMangement> wrap(const google::protobuf::Message &msg, const std::string spaceId)
{
    auto wrapper = std::make_unique<RemoteFileMangement>();
    wrapper->set_message_type(boost::algorithm::to_lower_copy(msg.GetDescriptor()->name()));
    msg.SerializeToString(wrapper->mutable_input());
    wrapper->set_space_id(spaceId);
    return wrapper;
}

template<typename AnswerType>
string ClusterProxyHelper::requestMessage(const google::protobuf::Message &msg,
                                          const std::chrono::milliseconds timeout)
{
    try
    {
        const auto answer = m_communicator->communicate<AnswerType>(
                    communication::ServerModule::REMOTE_FILES_MANAGER, *wrap(msg, m_spaceId), 2, timeout);
        return answer->worker_answer();
    }
    catch(communication::Exception &e)
    {
        LOG(WARNING) << "Communication error: " << e.what();
    }

    return {};
}

template<typename AnswerType>
string ClusterProxyHelper::requestMessage(const google::protobuf::Message &msg)
{
    try
    {
        const auto answer = m_communicator->communicate<AnswerType>(
                    communication::ServerModule::REMOTE_FILES_MANAGER, *wrap(msg, m_spaceId), 2);
        return answer->worker_answer();
    }
    catch(communication::Exception &e)
    {
        LOG(WARNING) << "Communication error: " << e.what();
    }

    return {};
}

string ClusterProxyHelper::requestAtom(const google::protobuf::Message &msg)
{
    try
    {
        const auto answer = m_communicator->communicate<Atom>(
                    communication::ServerModule::REMOTE_FILES_MANAGER, *wrap(msg, m_spaceId), 2);

        Atom atom;
        if(answer->has_worker_answer())
        {
            atom.ParseFromString(answer->worker_answer());
            return atom.value();
        }
    }
    catch(communication::Exception &e)
    {
        LOG(WARNING) << "Communication error: " << e.what();
    }

    return {};
}

//////////////////////
// Helper callbacks //
//////////////////////

int ClusterProxyHelper::sh_getattr(const char *path, struct stat *stbuf)
{
    // Just leave defaults and ignore this call
    return 0;
}

int ClusterProxyHelper::sh_access(const char *path, int mask)
{
    // We dont need this method, return success
    return 0;
}

int ClusterProxyHelper::sh_mknod(const char *path, mode_t mode, dev_t rdev)
{
    LOG(INFO) << "CluserProxyHelper mknod(path: " << string(path) << ")";

    CreateFile msg;
    msg.set_file_id(string(path));
    msg.set_mode(mode);

    return translateError(requestAtom(msg));
}

int ClusterProxyHelper::sh_unlink(const char *path)
{
    LOG(INFO) << "CluserProxyHelper unlink(path: " << string(path) << ")";

    DeleteFileAtStorage msg;
    msg.set_file_id(string(path));

    return translateError(requestAtom(msg));
}

int ClusterProxyHelper::sh_chmod(const char *path, mode_t mode)
{
    return 0;
}

int ClusterProxyHelper::sh_chown(const char *path, uid_t uid, gid_t gid)
{
    return 0;
}

int ClusterProxyHelper::sh_truncate(const char *path, off_t size)
{
    LOG(INFO) << "CluserProxyHelper truncate(path: " << string(path) << ", size: " << size << ")";

    TruncateFile msg;
    msg.set_file_id(string(path));
    msg.set_length(size);

    return translateError(requestAtom(msg));
}

int ClusterProxyHelper::sh_open(const char *path, struct fuse_file_info *fi)
{
    LOG(INFO) << "CluserProxyHelper open(path: " << string(path) << ")";

    // Proxy this call to Buffer Agent
    return m_bufferAgent.onOpen(string(path), fi);
}

int ClusterProxyHelper::sh_read(const char *path, char *buf, size_t size, off_t offset,
            struct fuse_file_info *fi)
{
    DLOG(INFO) << "CluserProxyHelper read(path: " << string(path) << ", size: " << size << ", offset: " << offset << ")";

    string tmpBuff;

    // Proxy this call to Buffer Agent
    int ret = m_bufferAgent.onRead(string(path), tmpBuff, size, offset, fi);
    if(ret > 0) {
        memcpy(buf, tmpBuff.c_str(), ret);
    }

    return ret;
}

int ClusterProxyHelper::sh_write(const char *path, const char *buf, size_t size,
             off_t offset, struct fuse_file_info *fi)
{
    DLOG(INFO) << "CluserProxyHelper write(path: " << string(path) << ", size: " << size << ", offset: " << offset << ")";

    // Proxy this call to Buffer Agent
    return m_bufferAgent.onWrite(string(path), string(buf, size), size, offset, fi);
}

int ClusterProxyHelper::sh_release(const char *path, struct fuse_file_info *fi)
{
    LOG(INFO) << "CluserProxyHelper release(path: " << string(path) << ")";

    // Proxy this call to Buffer Agent
    return m_bufferAgent.onRelease(string(path), fi);
}

int ClusterProxyHelper::sh_flush(const char *path, struct fuse_file_info *fi)
{
    LOG(INFO) << "CluserProxyHelper flush(path: " << string(path) << ")";

    // Proxy this call to Buffer Agent
    return m_bufferAgent.onFlush(string(path), fi);
}

int ClusterProxyHelper::sh_fsync(const char *path, int isdatasync,
             struct fuse_file_info *fi)
{
    /* Just a stub.     This method is optional and can safely be left
       unimplemented */

    (void) path;
    (void) isdatasync;
    (void) fi;
    return 0;
}

int ClusterProxyHelper::sh_mkdir(const char *path, mode_t mode)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
               off_t offset, struct fuse_file_info *fi)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_statfs(const char *path, struct statvfs *stbuf)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_rmdir(const char *path)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_symlink(const char *from, const char *to)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_rename(const char *from, const char *to)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_link(const char *from, const char *to)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_readlink(const char *path, char *buf, size_t size)
{
    return ENOTSUP;
}

#ifdef HAVE_POSIX_FALLOCATE
int ClusterProxyHelper::sh_fallocate(const char *path, int mode,
            off_t offset, off_t length, struct fuse_file_info *fi)
{
    return ENOTSUP;
}
#endif  /* HAVE_POSIX_FALLOCATE */

#ifdef HAVE_UTIMENSAT
int ClusterProxyHelper::sh_utimens(const char *path, const struct timespec ts[2])
{
    return 0;
}
#endif /* HAVE_UTIMENSAT */

#ifdef HAVE_SETXATTR
/* xattr operations are optional and can safely be left unimplemented */
int ClusterProxyHelper::sh_setxattr(const char *path, const char *name, const char *value,
            size_t size, int flags)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_getxattr(const char *path, const char *name, char *value,
            size_t size)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_listxattr(const char *path, char *list, size_t size)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_removexattr(const char *path, const char *name)
{
    return ENOTSUP;
}

#endif /* HAVE_SETXATTR */

int ClusterProxyHelper::doWrite(const string &path, const std::string &buf, size_t size, off_t offset, ffi_type)
{
    LOG(INFO) << "CluserProxyHelper doWrite(path: " << string(path) << ", size: " << size << ", offset: " << offset << ")";

    WriteFile msg;
    msg.set_file_id(path);
    msg.set_data(buf);
    msg.set_offset(offset);

    WriteInfo answer;
    string inputData = msg.SerializeAsString();

    if(!answer.ParseFromString(requestMessage<WriteInfo>(msg)))
    {
        LOG(WARNING) << "Cannot parse answer for file: " << string(path);
        return translateError(VEIO);
    }

    DLOG(INFO) << "CluserProxyHelper write answer_status: " << answer.answer_status() << ", write real size: " << answer.bytes_written();

    int error = translateError(answer.answer_status());
    if(error == 0) return answer.bytes_written();
    else           return error;
    return 0;
}

int ClusterProxyHelper::doRead(const string &path, std::string &buf, size_t size, off_t offset, ffi_type)
{
    ReadFile msg;
    msg.set_file_id(string(path));
    msg.set_size(size);
    msg.set_offset(offset);

    FileData answer;
    string inputData = msg.SerializeAsString();

    std::chrono::milliseconds timeout{size * 2}; // 2ms for each byte (minimum of 500B/s);

    if(!answer.ParseFromString(requestMessage<FileData>(msg, timeout)))
    {
        LOG(WARNING) << "Cannot parse answer for file: " << string(path);
        return translateError(VEIO);
    }

    DLOG(INFO) << "CluserProxyHelper(offset: " << offset << ", size: " << size << ") read answer_status: " << answer.answer_status() << ", read real size: " << answer.data().size();

    if(answer.answer_status() == VOK) {
        size_t readSize = (answer.data().size() > size ? size : answer.data().size());

        buf = answer.data();

        // if(answer.data().size() != size)
        //     LOG(WARNING) << "read for file: " << string(path) << " returned " << answer.data().size() << "bytes. Expected: " << size;

        return readSize;

    } else if(answer.answer_status() == "ok:TODO2") {
        /// TODO: implement big read
        LOG(ERROR) << "Cluster requested to read file (" << string(path) << ") directly over TCP/IP which is not implemented yet";
        return -ENOTSUP;
    } else
        return translateError(answer.answer_status());
    return 0;
}

ClusterProxyHelper::ClusterProxyHelper(std::shared_ptr<communication::Communicator> communicator,
                                       const BufferLimits &limits, const ArgsMap &args)
  : m_bufferAgent(
        limits,
        std::bind(&ClusterProxyHelper::doWrite, this, _1, _2, _3, _4, _5),
        std::bind(&ClusterProxyHelper::doRead, this, _1, _2, _3, _4, _5))
  , m_communicator{std::move(communicator)}
{
    m_clusterHostname = args.count("cluster_hostname") ?
                boost::any_cast<std::string>(args.at("cluster_hostname")) : std::string{};

    m_clusterPort = args.count("cluster_port") ?
                boost::any_cast<unsigned int>(args.at("cluster_port")) : 0;

    const auto arg = srvArg(0);
    m_spaceId = args.count(arg)
                    ? boost::any_cast<std::string>(args.at(arg))
                    : string();
}

} // namespace helpers
} // namespace one
<commit_msg>bump minimal timeout value<commit_after>/**
 * @file clusterProxyHelper.cc
 * @author Rafal Slota
 * @copyright (C) 2013 ACK CYFRONET AGH
 * @copyright This software is released under the MIT license cited in 'LICENSE.txt'
 */

#include "clusterProxyHelper.h"

#include "communication/communicator.h"
#include "communication/exception.h"
#include "logging.h"
#include "remote_file_management.pb.h"

#include <boost/algorithm/string/case_conv.hpp>
#include <boost/any.hpp>

#include <functional>

using namespace std;
using namespace std::placeholders;
using namespace one::clproto::remote_file_management;
using namespace one::clproto::communication_protocol;

namespace one {
namespace helpers {

std::unique_ptr<RemoteFileMangement> wrap(const google::protobuf::Message &msg, const std::string spaceId)
{
    auto wrapper = std::make_unique<RemoteFileMangement>();
    wrapper->set_message_type(boost::algorithm::to_lower_copy(msg.GetDescriptor()->name()));
    msg.SerializeToString(wrapper->mutable_input());
    wrapper->set_space_id(spaceId);
    return wrapper;
}

template<typename AnswerType>
string ClusterProxyHelper::requestMessage(const google::protobuf::Message &msg,
                                          const std::chrono::milliseconds timeout)
{
    try
    {
        const auto answer = m_communicator->communicate<AnswerType>(
                    communication::ServerModule::REMOTE_FILES_MANAGER, *wrap(msg, m_spaceId), 2, timeout);
        return answer->worker_answer();
    }
    catch(communication::Exception &e)
    {
        LOG(WARNING) << "Communication error: " << e.what();
    }

    return {};
}

template<typename AnswerType>
string ClusterProxyHelper::requestMessage(const google::protobuf::Message &msg)
{
    try
    {
        const auto answer = m_communicator->communicate<AnswerType>(
                    communication::ServerModule::REMOTE_FILES_MANAGER, *wrap(msg, m_spaceId), 2);
        return answer->worker_answer();
    }
    catch(communication::Exception &e)
    {
        LOG(WARNING) << "Communication error: " << e.what();
    }

    return {};
}

string ClusterProxyHelper::requestAtom(const google::protobuf::Message &msg)
{
    try
    {
        const auto answer = m_communicator->communicate<Atom>(
                    communication::ServerModule::REMOTE_FILES_MANAGER, *wrap(msg, m_spaceId), 2);

        Atom atom;
        if(answer->has_worker_answer())
        {
            atom.ParseFromString(answer->worker_answer());
            return atom.value();
        }
    }
    catch(communication::Exception &e)
    {
        LOG(WARNING) << "Communication error: " << e.what();
    }

    return {};
}

//////////////////////
// Helper callbacks //
//////////////////////

int ClusterProxyHelper::sh_getattr(const char *path, struct stat *stbuf)
{
    // Just leave defaults and ignore this call
    return 0;
}

int ClusterProxyHelper::sh_access(const char *path, int mask)
{
    // We dont need this method, return success
    return 0;
}

int ClusterProxyHelper::sh_mknod(const char *path, mode_t mode, dev_t rdev)
{
    LOG(INFO) << "CluserProxyHelper mknod(path: " << string(path) << ")";

    CreateFile msg;
    msg.set_file_id(string(path));
    msg.set_mode(mode);

    return translateError(requestAtom(msg));
}

int ClusterProxyHelper::sh_unlink(const char *path)
{
    LOG(INFO) << "CluserProxyHelper unlink(path: " << string(path) << ")";

    DeleteFileAtStorage msg;
    msg.set_file_id(string(path));

    return translateError(requestAtom(msg));
}

int ClusterProxyHelper::sh_chmod(const char *path, mode_t mode)
{
    return 0;
}

int ClusterProxyHelper::sh_chown(const char *path, uid_t uid, gid_t gid)
{
    return 0;
}

int ClusterProxyHelper::sh_truncate(const char *path, off_t size)
{
    LOG(INFO) << "CluserProxyHelper truncate(path: " << string(path) << ", size: " << size << ")";

    TruncateFile msg;
    msg.set_file_id(string(path));
    msg.set_length(size);

    return translateError(requestAtom(msg));
}

int ClusterProxyHelper::sh_open(const char *path, struct fuse_file_info *fi)
{
    LOG(INFO) << "CluserProxyHelper open(path: " << string(path) << ")";

    // Proxy this call to Buffer Agent
    return m_bufferAgent.onOpen(string(path), fi);
}

int ClusterProxyHelper::sh_read(const char *path, char *buf, size_t size, off_t offset,
            struct fuse_file_info *fi)
{
    DLOG(INFO) << "CluserProxyHelper read(path: " << string(path) << ", size: " << size << ", offset: " << offset << ")";

    string tmpBuff;

    // Proxy this call to Buffer Agent
    int ret = m_bufferAgent.onRead(string(path), tmpBuff, size, offset, fi);
    if(ret > 0) {
        memcpy(buf, tmpBuff.c_str(), ret);
    }

    return ret;
}

int ClusterProxyHelper::sh_write(const char *path, const char *buf, size_t size,
             off_t offset, struct fuse_file_info *fi)
{
    DLOG(INFO) << "CluserProxyHelper write(path: " << string(path) << ", size: " << size << ", offset: " << offset << ")";

    // Proxy this call to Buffer Agent
    return m_bufferAgent.onWrite(string(path), string(buf, size), size, offset, fi);
}

int ClusterProxyHelper::sh_release(const char *path, struct fuse_file_info *fi)
{
    LOG(INFO) << "CluserProxyHelper release(path: " << string(path) << ")";

    // Proxy this call to Buffer Agent
    return m_bufferAgent.onRelease(string(path), fi);
}

int ClusterProxyHelper::sh_flush(const char *path, struct fuse_file_info *fi)
{
    LOG(INFO) << "CluserProxyHelper flush(path: " << string(path) << ")";

    // Proxy this call to Buffer Agent
    return m_bufferAgent.onFlush(string(path), fi);
}

int ClusterProxyHelper::sh_fsync(const char *path, int isdatasync,
             struct fuse_file_info *fi)
{
    /* Just a stub.     This method is optional and can safely be left
       unimplemented */

    (void) path;
    (void) isdatasync;
    (void) fi;
    return 0;
}

int ClusterProxyHelper::sh_mkdir(const char *path, mode_t mode)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
               off_t offset, struct fuse_file_info *fi)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_statfs(const char *path, struct statvfs *stbuf)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_rmdir(const char *path)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_symlink(const char *from, const char *to)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_rename(const char *from, const char *to)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_link(const char *from, const char *to)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_readlink(const char *path, char *buf, size_t size)
{
    return ENOTSUP;
}

#ifdef HAVE_POSIX_FALLOCATE
int ClusterProxyHelper::sh_fallocate(const char *path, int mode,
            off_t offset, off_t length, struct fuse_file_info *fi)
{
    return ENOTSUP;
}
#endif  /* HAVE_POSIX_FALLOCATE */

#ifdef HAVE_UTIMENSAT
int ClusterProxyHelper::sh_utimens(const char *path, const struct timespec ts[2])
{
    return 0;
}
#endif /* HAVE_UTIMENSAT */

#ifdef HAVE_SETXATTR
/* xattr operations are optional and can safely be left unimplemented */
int ClusterProxyHelper::sh_setxattr(const char *path, const char *name, const char *value,
            size_t size, int flags)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_getxattr(const char *path, const char *name, char *value,
            size_t size)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_listxattr(const char *path, char *list, size_t size)
{
    return ENOTSUP;
}

int ClusterProxyHelper::sh_removexattr(const char *path, const char *name)
{
    return ENOTSUP;
}

#endif /* HAVE_SETXATTR */

int ClusterProxyHelper::doWrite(const string &path, const std::string &buf, size_t size, off_t offset, ffi_type)
{
    LOG(INFO) << "CluserProxyHelper doWrite(path: " << string(path) << ", size: " << size << ", offset: " << offset << ")";

    WriteFile msg;
    msg.set_file_id(path);
    msg.set_data(buf);
    msg.set_offset(offset);

    WriteInfo answer;
    string inputData = msg.SerializeAsString();

    if(!answer.ParseFromString(requestMessage<WriteInfo>(msg)))
    {
        LOG(WARNING) << "Cannot parse answer for file: " << string(path);
        return translateError(VEIO);
    }

    DLOG(INFO) << "CluserProxyHelper write answer_status: " << answer.answer_status() << ", write real size: " << answer.bytes_written();

    int error = translateError(answer.answer_status());
    if(error == 0) return answer.bytes_written();
    else           return error;
    return 0;
}

int ClusterProxyHelper::doRead(const string &path, std::string &buf, size_t size, off_t offset, ffi_type)
{
    ReadFile msg;
    msg.set_file_id(string(path));
    msg.set_size(size);
    msg.set_offset(offset);

    FileData answer;
    string inputData = msg.SerializeAsString();

    std::chrono::milliseconds timeout{500 + size * 2}; //500ms + 2ms for each byte (minimum of 500B/s);

    if(!answer.ParseFromString(requestMessage<FileData>(msg, timeout)))
    {
        LOG(WARNING) << "Cannot parse answer for file: " << string(path);
        return translateError(VEIO);
    }

    DLOG(INFO) << "CluserProxyHelper(offset: " << offset << ", size: " << size << ") read answer_status: " << answer.answer_status() << ", read real size: " << answer.data().size();

    if(answer.answer_status() == VOK) {
        size_t readSize = (answer.data().size() > size ? size : answer.data().size());

        buf = answer.data();

        // if(answer.data().size() != size)
        //     LOG(WARNING) << "read for file: " << string(path) << " returned " << answer.data().size() << "bytes. Expected: " << size;

        return readSize;

    } else if(answer.answer_status() == "ok:TODO2") {
        /// TODO: implement big read
        LOG(ERROR) << "Cluster requested to read file (" << string(path) << ") directly over TCP/IP which is not implemented yet";
        return -ENOTSUP;
    } else
        return translateError(answer.answer_status());
    return 0;
}

ClusterProxyHelper::ClusterProxyHelper(std::shared_ptr<communication::Communicator> communicator,
                                       const BufferLimits &limits, const ArgsMap &args)
  : m_bufferAgent(
        limits,
        std::bind(&ClusterProxyHelper::doWrite, this, _1, _2, _3, _4, _5),
        std::bind(&ClusterProxyHelper::doRead, this, _1, _2, _3, _4, _5))
  , m_communicator{std::move(communicator)}
{
    m_clusterHostname = args.count("cluster_hostname") ?
                boost::any_cast<std::string>(args.at("cluster_hostname")) : std::string{};

    m_clusterPort = args.count("cluster_port") ?
                boost::any_cast<unsigned int>(args.at("cluster_port")) : 0;

    const auto arg = srvArg(0);
    m_spaceId = args.count(arg)
                    ? boost::any_cast<std::string>(args.at(arg))
                    : string();
}

} // namespace helpers
} // namespace one
<|endoftext|>


<commit_before>// Copyright (c) 2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <string>

#include "version.h"

// Name of client reported in the 'version' message. Report the same name
// for both bitcoind and bitcoin-qt, to make it harder for attackers to
// target servers or GUI users specifically.
const std::string CLIENT_NAME("2GiveCoin");

// Client version number
#define CLIENT_VERSION_SUFFIX   "-RC5-DEV-20160603"
#define BUILD_DATE __DATE__ ", " __TIME__

// The following part of the code determines the CLIENT_BUILD variable.
// Several mechanisms are used for this:
// * first, if HAVE_BUILD_INFO is defined, include build.h, a file that is
//   generated by the build environment, possibly containing the output
//   of git-describe in a macro called BUILD_DESC
// * secondly, if this is an exported version of the code, GIT_ARCHIVE will
//   be defined (automatically using the export-subst git attribute), and
//   GIT_COMMIT will contain the commit id.
// * then, three options exist for determining CLIENT_BUILD:
//   * if BUILD_DESC is defined, use that literally (output of git-describe)
//   * if not, but GIT_COMMIT is defined, use v[maj].[min].[rev].[build]-g[commit]
//   * otherwise, use v[maj].[min].[rev].[build]-unk
// finally CLIENT_VERSION_SUFFIX is added

// First, include build.h if requested
#ifdef HAVE_BUILD_INFO
#    include "build.h"
#endif

// git will put "#define GIT_ARCHIVE 1" on the next line inside archives.
//#define GIT_ARCHIVE 1
#ifdef GIT_ARCHIVE
#    define GIT_COMMIT_ID ""
#    define GIT_COMMIT_DATE "$Format:%cD$"
#endif

#define BUILD_DESC_FROM_COMMIT(maj,min,rev,build,commit) \
    "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "" commit

#define BUILD_DESC_FROM_UNKNOWN(maj,min,rev,build) \
    "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) ""

#ifndef BUILD_DESC
#    ifdef GIT_COMMIT_ID
#        define BUILD_DESC BUILD_DESC_FROM_COMMIT(DISPLAY_VERSION_MAJOR, DISPLAY_VERSION_MINOR, DISPLAY_VERSION_REVISION, DISPLAY_VERSION_BUILD, GIT_COMMIT_ID)
#    else
#        define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(DISPLAY_VERSION_MAJOR, DISPLAY_VERSION_MINOR, DISPLAY_VERSION_REVISION, DISPLAY_VERSION_BUILD)
#    endif
#endif

#ifndef BUILD_DATE
#    ifdef GIT_COMMIT_DATE
#        define BUILD_DATE GIT_COMMIT_DATE
#    else
#        define BUILD_DATE __DATE__ ", " __TIME__
#    endif
#endif

const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX);
const std::string CLIENT_DATE(BUILD_DATE);
<commit_msg>Updated version string<commit_after>// Copyright (c) 2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <string>

#include "version.h"

// Name of client reported in the 'version' message. Report the same name
// for both bitcoind and bitcoin-qt, to make it harder for attackers to
// target servers or GUI users specifically.
const std::string CLIENT_NAME("2GiveCoin");

// Client version number
#define CLIENT_VERSION_SUFFIX   "-RC5-DEV-20160604"
#define BUILD_DATE __DATE__ ", " __TIME__

// The following part of the code determines the CLIENT_BUILD variable.
// Several mechanisms are used for this:
// * first, if HAVE_BUILD_INFO is defined, include build.h, a file that is
//   generated by the build environment, possibly containing the output
//   of git-describe in a macro called BUILD_DESC
// * secondly, if this is an exported version of the code, GIT_ARCHIVE will
//   be defined (automatically using the export-subst git attribute), and
//   GIT_COMMIT will contain the commit id.
// * then, three options exist for determining CLIENT_BUILD:
//   * if BUILD_DESC is defined, use that literally (output of git-describe)
//   * if not, but GIT_COMMIT is defined, use v[maj].[min].[rev].[build]-g[commit]
//   * otherwise, use v[maj].[min].[rev].[build]-unk
// finally CLIENT_VERSION_SUFFIX is added

// First, include build.h if requested
#ifdef HAVE_BUILD_INFO
#    include "build.h"
#endif

// git will put "#define GIT_ARCHIVE 1" on the next line inside archives.
//#define GIT_ARCHIVE 1
#ifdef GIT_ARCHIVE
#    define GIT_COMMIT_ID ""
#    define GIT_COMMIT_DATE "$Format:%cD$"
#endif

#define BUILD_DESC_FROM_COMMIT(maj,min,rev,build,commit) \
    "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "" commit

#define BUILD_DESC_FROM_UNKNOWN(maj,min,rev,build) \
    "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) ""

#ifndef BUILD_DESC
#    ifdef GIT_COMMIT_ID
#        define BUILD_DESC BUILD_DESC_FROM_COMMIT(DISPLAY_VERSION_MAJOR, DISPLAY_VERSION_MINOR, DISPLAY_VERSION_REVISION, DISPLAY_VERSION_BUILD, GIT_COMMIT_ID)
#    else
#        define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(DISPLAY_VERSION_MAJOR, DISPLAY_VERSION_MINOR, DISPLAY_VERSION_REVISION, DISPLAY_VERSION_BUILD)
#    endif
#endif

#ifndef BUILD_DATE
#    ifdef GIT_COMMIT_DATE
#        define BUILD_DATE GIT_COMMIT_DATE
#    else
#        define BUILD_DATE __DATE__ ", " __TIME__
#    endif
#endif

const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX);
const std::string CLIENT_DATE(BUILD_DATE);
<|endoftext|>


<commit_before>#include <utility>
#include <istream>
#include <iostream>

#include "reader.hh"
#include "vm.hh"
#include "util.hh"
#include "lisp_ptr.hh"
#include "token.hh"
#include "number.hh"
#include "cons.hh"
#include "cons_util.hh"
#include "symbol.hh"

using namespace std;

namespace {

Lisp_ptr read_la(istream& f, Token&&);

Lisp_ptr read_list(istream& f){
  Token t = tokenize(f);

  // first check
  if(!t){
    throw zs_error("reader error: reached EOF in a list.\n");
  }else if(t.type() == Token::Type::notation){
    auto n = t.get<Token::Notation>();
    if(n == Token::Notation::r_paren){ // empty list
      return Cons::NIL;
    }else if(n == Token::Notation::dot){
      throw zs_error("reader error: dotted list has no car.\n");
    }
  }

  // main loop
  GrowList gl;

  while(1){
    Lisp_ptr datum{read_la(f, move(t))};
    if(!datum){
      return Lisp_ptr{};
    }

    gl.push(datum);

    // check next token
    t = tokenize(f);
    if(!t){
      throw zs_error("reader error: reached EOF in a list.\n");
    }else if(t.type() == Token::Type::notation){
      auto n = t.get<Token::Notation>();
      if(n == Token::Notation::r_paren){ // proper list
        return gl.extract();
      }else if(n == Token::Notation::dot){ // dotted list
        auto ret = gl.extract_with_tail(read(f));
        t = tokenize(f);
        if(t.type() != Token::Type::notation
           || t.get<Token::Notation>() != Token::Notation::r_paren){
          throw zs_error("reader error: dotted list has two or more cdrs.\n");
        }
        return ret;
      }
    }
  }

  UNEXP_DEFAULT(); // should not come here.
}

Lisp_ptr read_vector(istream& f){
  Vector* v = new Vector();

  while(1){
    auto t = tokenize(f);
    if(!t){
      delete v;
      throw zs_error("reader error: reached EOF in a vector.\n");
    }else if((t.type() == Token::Type::notation)
             && (t.get<Token::Notation>()
                 == Token::Notation::r_paren)){
      return Lisp_ptr{v};
    }else{
      Lisp_ptr datum{read_la(f, move(t))};
      if(!datum){
        return Lisp_ptr{};
      }

      v->emplace_back(datum);
    }
  }

  UNEXP_DEFAULT(); // should not come here.
}

Lisp_ptr read_abbrev(const char* name, istream& f){
  return make_cons_list({intern(vm.symtable(), name), read(f)});
}

Lisp_ptr read_la(istream& f, Token&& tok){
  switch(tok.type()){
    // simple datum
  case Token::Type::boolean:
    return Lisp_ptr(tok.move<bool>());

  case Token::Type::number:
    return Lisp_ptr(new Number(tok.move<Number>()));

  case Token::Type::character:
    return (tok.get<char>() == EOF) ? Lisp_ptr{} : Lisp_ptr{tok.move<char>()};

  case Token::Type::string:
    return Lisp_ptr(new String(tok.move<string>()));

  case Token::Type::identifier:
    return Lisp_ptr{intern(vm.symtable(), tok.move<string>())};

    // compound datum
  case Token::Type::notation:
    switch(auto n = tok.move<Token::Notation>()){

    case Token::Notation::l_paren: // list
      return read_list(f);

    case Token::Notation::vector_paren: // vector
      return read_vector(f);

      // abbrev prefix
    case Token::Notation::quote:
      return read_abbrev("quote", f);

    case Token::Notation::quasiquote:
      return read_abbrev("quasiquote", f);

    case Token::Notation::comma:
      return read_abbrev("unquote", f);

    case Token::Notation::comma_at:
      return read_abbrev("unquote-splicing", f);

    case Token::Notation::l_bracket:
    case Token::Notation::l_brace:
      throw make_zs_error("reader error: not supported notation! (type=%s)\n",
                          stringify(n));

    case Token::Notation::r_paren:
    case Token::Notation::r_bracket:
    case Token::Notation::r_brace:
      throw make_zs_error("reader error: closing notation appeared alone! (type=%s)\n",
                          stringify(n));

    case Token::Notation::dot:
    case Token::Notation::bar:
    default:
      throw make_zs_error("reader error: unexpected notation was passed! (type=%s)\n",
                          stringify(n));
    }

  case Token::Type::uninitialized:
    return Lisp_ptr{};

  default:
    UNEXP_DEFAULT();
  }
}

} // namespace

Lisp_ptr read(istream& f){
  return read_la(f, tokenize(f));
}
<commit_msg>changed EOF traring (2)<commit_after>#include <utility>
#include <istream>
#include <iostream>

#include "reader.hh"
#include "vm.hh"
#include "util.hh"
#include "lisp_ptr.hh"
#include "token.hh"
#include "number.hh"
#include "cons.hh"
#include "cons_util.hh"
#include "symbol.hh"

using namespace std;

namespace {

Lisp_ptr read_la(istream& f, Token&&);

Lisp_ptr read_list(istream& f){
  Token t = tokenize(f);

  // first check
  if(!t){
    throw zs_error("reader error: reached EOF in a list.\n");
  }else if(t.type() == Token::Type::notation){
    auto n = t.get<Token::Notation>();
    if(n == Token::Notation::r_paren){ // empty list
      return Cons::NIL;
    }else if(n == Token::Notation::dot){
      throw zs_error("reader error: dotted list has no car.\n");
    }
  }

  // main loop
  GrowList gl;

  while(1){
    gl.push(read_la(f, move(t)));

    // check next token
    t = tokenize(f);
    if(!t){
      throw zs_error("reader error: reached EOF in a list.\n");
    }else if(t.type() == Token::Type::notation){
      auto n = t.get<Token::Notation>();
      if(n == Token::Notation::r_paren){ // proper list
        return gl.extract();
      }else if(n == Token::Notation::dot){ // dotted list
        auto ret = gl.extract_with_tail(read(f));
        t = tokenize(f);
        if(t.type() != Token::Type::notation
           || t.get<Token::Notation>() != Token::Notation::r_paren){
          throw zs_error("reader error: dotted list has two or more cdrs.\n");
        }
        return ret;
      }
    }
  }

  UNEXP_DEFAULT(); // should not come here.
}

Lisp_ptr read_vector(istream& f){
  Vector* v = new Vector();

  while(1){
    auto t = tokenize(f);
    if(!t){
      delete v;
      throw zs_error("reader error: reached EOF in a vector.\n");
    }else if((t.type() == Token::Type::notation)
             && (t.get<Token::Notation>()
                 == Token::Notation::r_paren)){
      return Lisp_ptr{v};
    }else{
      v->emplace_back(read_la(f, move(t)));
    }
  }

  UNEXP_DEFAULT(); // should not come here.
}

Lisp_ptr read_abbrev(const char* name, istream& f){
  return make_cons_list({intern(vm.symtable(), name), read(f)});
}

Lisp_ptr read_la(istream& f, Token&& tok){
  switch(tok.type()){
    // simple datum
  case Token::Type::boolean:
    return Lisp_ptr(tok.move<bool>());

  case Token::Type::number:
    return Lisp_ptr(new Number(tok.move<Number>()));

  case Token::Type::character:
    return (tok.get<char>() == EOF) ? Lisp_ptr{} : Lisp_ptr{tok.move<char>()};

  case Token::Type::string:
    return Lisp_ptr(new String(tok.move<string>()));

  case Token::Type::identifier:
    return Lisp_ptr{intern(vm.symtable(), tok.move<string>())};

    // compound datum
  case Token::Type::notation:
    switch(auto n = tok.move<Token::Notation>()){

    case Token::Notation::l_paren: // list
      return read_list(f);

    case Token::Notation::vector_paren: // vector
      return read_vector(f);

      // abbrev prefix
    case Token::Notation::quote:
      return read_abbrev("quote", f);

    case Token::Notation::quasiquote:
      return read_abbrev("quasiquote", f);

    case Token::Notation::comma:
      return read_abbrev("unquote", f);

    case Token::Notation::comma_at:
      return read_abbrev("unquote-splicing", f);

    case Token::Notation::l_bracket:
    case Token::Notation::l_brace:
      throw make_zs_error("reader error: not supported notation! (type=%s)\n",
                          stringify(n));

    case Token::Notation::r_paren:
    case Token::Notation::r_bracket:
    case Token::Notation::r_brace:
      throw make_zs_error("reader error: closing notation appeared alone! (type=%s)\n",
                          stringify(n));

    case Token::Notation::dot:
    case Token::Notation::bar:
    default:
      throw make_zs_error("reader error: unexpected notation was passed! (type=%s)\n",
                          stringify(n));
    }

  case Token::Type::uninitialized:
    return Lisp_ptr{};

  default:
    UNEXP_DEFAULT();
  }
}

} // namespace

Lisp_ptr read(istream& f){
  return read_la(f, tokenize(f));
}
<|endoftext|>


<commit_before>/*
        ##########    Copyright (C) 2015 Vincenzo Pacella
        ##      ##    Distributed under MIT license, see file LICENSE
        ##      ##    or <http://opensource.org/licenses/MIT>
        ##      ##
##########      ############################################################# shaduzlabs.com #####*/

#include "catch.hpp"

#include <gfx/Canvas.h>

namespace sl
{
namespace cabl
{
namespace test
{

//--------------------------------------------------------------------------------------------------

//  ------------------
// | 0000000000000000 |
// | 0000000000000000 |
// | 0000000000000000 |
// | 0000000000000000 |
// | 0000000000000000 |
//  ------------------

TEST_CASE("Constructors", "[gfx/Canvas]")
{
  Canvas c(16, 5, Canvas::Allocation::OneBytePacksOneRowOfEightPixels);
  CHECK(c.width() == 16);
  CHECK(c.height() == 5);
}

//--------------------------------------------------------------------------------------------------

} // namespace test
} // namespace cabl
} // namespace sl
<commit_msg>renamed Canvas unit test<commit_after>/*
        ##########    Copyright (C) 2015 Vincenzo Pacella
        ##      ##    Distributed under MIT license, see file LICENSE
        ##      ##    or <http://opensource.org/licenses/MIT>
        ##      ##
##########      ############################################################# shaduzlabs.com #####*/

#include "catch.hpp"

#include <gfx/Canvas.h>

namespace sl
{
namespace cabl
{
namespace test
{

//--------------------------------------------------------------------------------------------------

//  ------------------
// | 0000000000000000 |
// | 0000000000000000 |
// | 0000000000000000 |
// | 0000000000000000 |
// | 0000000000000000 |
//  ------------------

TEST_CASE("Canvas constructor", "[gfx/Canvas]")
{
  Canvas c(16, 5, Canvas::Allocation::OneBytePacksOneRowOfEightPixels);
  CHECK(c.width() == 16);
  CHECK(c.height() == 5);
}

//--------------------------------------------------------------------------------------------------

} // namespace test
} // namespace cabl
} // namespace sl
<|endoftext|>


<commit_before>// Copyright (c) 2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <string>

#include "version.h"

// Name of client reported in the 'version' message. Report the same name
// for both bitcoind and bitcoin-qt, to make it harder for attackers to
// target servers or GUI users specifically.
const std::string CLIENT_NAME("Satoshi");

// Client version number
#define CLIENT_VERSION_SUFFIX   "-hobo"

// The following part of the code determines the CLIENT_BUILD variable.
// Several mechanisms are used for this:
// * first, if HAVE_BUILD_INFO is defined, include build.h, a file that is
//   generated by the build environment, possibly containing the output
//   of git-describe in a macro called BUILD_DESC
// * secondly, if this is an exported version of the code, GIT_ARCHIVE will
//   be defined (automatically using the export-subst git attribute), and
//   GIT_COMMIT will contain the commit id.
// * then, three options exist for determining CLIENT_BUILD:
//   * if BUILD_DESC is defined, use that literally (output of git-describe)
//   * if not, but GIT_COMMIT is defined, use v[maj].[min].[rev].[build]-g[commit]
//   * otherwise, use v[maj].[min].[rev].[build]-unk
// finally CLIENT_VERSION_SUFFIX is added

// First, include build.h if requested
#ifdef HAVE_BUILD_INFO
#    include "build.h"
#endif

// git will put "#define GIT_ARCHIVE 1" on the next line inside archives.
#define GIT_ARCHIVE 1
#ifdef GIT_ARCHIVE
#    define GIT_COMMIT_ID "b3d0643"
#    define GIT_COMMIT_DATE "Fri Nov 01 01:56:53 2013"
#endif

#define BUILD_DESC_FROM_COMMIT(maj,min,rev,build,commit) \
    "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-g" commit

#define BUILD_DESC_FROM_UNKNOWN(maj,min,rev,build) \
    "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-unk"

#ifndef BUILD_DESC
#    ifdef GIT_COMMIT_ID
#        define BUILD_DESC BUILD_DESC_FROM_COMMIT(DISPLAY_VERSION_MAJOR, DISPLAY_VERSION_MINOR, DISPLAY_VERSION_REVISION, DISPLAY_VERSION_BUILD, GIT_COMMIT_ID)
#    else
#        define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(DISPLAY_VERSION_MAJOR, DISPLAY_VERSION_MINOR, DISPLAY_VERSION_REVISION, DISPLAY_VERSION_BUILD)
#    endif
#endif

#ifndef BUILD_DATE
#    ifdef GIT_COMMIT_DATE
#        define BUILD_DATE GIT_COMMIT_DATE
#    else
#        define BUILD_DATE __DATE__ ", " __TIME__
#    endif
#endif

const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX);
const std::string CLIENT_DATE(BUILD_DATE);
<commit_msg>Created HoboNickels subver<commit_after>// Copyright (c) 2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <string>

#include "version.h"

// Name of client reported in the 'version' message. Report the same name
// for both bitcoind and bitcoin-qt, to make it harder for attackers to
// target servers or GUI users specifically.
const std::string CLIENT_NAME("HoboNickels");

// Client version number
#define CLIENT_VERSION_SUFFIX   "-hobo"

// The following part of the code determines the CLIENT_BUILD variable.
// Several mechanisms are used for this:
// * first, if HAVE_BUILD_INFO is defined, include build.h, a file that is
//   generated by the build environment, possibly containing the output
//   of git-describe in a macro called BUILD_DESC
// * secondly, if this is an exported version of the code, GIT_ARCHIVE will
//   be defined (automatically using the export-subst git attribute), and
//   GIT_COMMIT will contain the commit id.
// * then, three options exist for determining CLIENT_BUILD:
//   * if BUILD_DESC is defined, use that literally (output of git-describe)
//   * if not, but GIT_COMMIT is defined, use v[maj].[min].[rev].[build]-g[commit]
//   * otherwise, use v[maj].[min].[rev].[build]-unk
// finally CLIENT_VERSION_SUFFIX is added

// First, include build.h if requested
#ifdef HAVE_BUILD_INFO
#    include "build.h"
#endif

// git will put "#define GIT_ARCHIVE 1" on the next line inside archives.
#define GIT_ARCHIVE 1
#ifdef GIT_ARCHIVE
#    define GIT_COMMIT_ID "b3d0643"
#    define GIT_COMMIT_DATE "Fri Nov 01 01:56:53 2013"
#endif

#define BUILD_DESC_FROM_COMMIT(maj,min,rev,build,commit) \
    "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-g" commit

#define BUILD_DESC_FROM_UNKNOWN(maj,min,rev,build) \
    "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-unk"

#ifndef BUILD_DESC
#    ifdef GIT_COMMIT_ID
#        define BUILD_DESC BUILD_DESC_FROM_COMMIT(DISPLAY_VERSION_MAJOR, DISPLAY_VERSION_MINOR, DISPLAY_VERSION_REVISION, DISPLAY_VERSION_BUILD, GIT_COMMIT_ID)
#    else
#        define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(DISPLAY_VERSION_MAJOR, DISPLAY_VERSION_MINOR, DISPLAY_VERSION_REVISION, DISPLAY_VERSION_BUILD)
#    endif
#endif

#ifndef BUILD_DATE
#    ifdef GIT_COMMIT_DATE
#        define BUILD_DATE GIT_COMMIT_DATE
#    else
#        define BUILD_DATE __DATE__ ", " __TIME__
#    endif
#endif

const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX);
const std::string CLIENT_DATE(BUILD_DATE);
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: pgbrksh.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-08 21:43:47 $
 *
 *  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 SC_PGBRKSH_HXX
#define SC_PGBRKSH_HXX

#ifndef _SFXMODULE_HXX //autogen
#include <sfx2/module.hxx>
#endif
#ifndef _SFX_SHELL_HXX //autogen
#include <sfx2/shell.hxx>
#endif

#include "shellids.hxx"

class ScTabViewShell;

class ScPageBreakShell : public SfxShell
{
public:
    TYPEINFO();
    SFX_DECL_INTERFACE(SCID_PAGEBREAK_SHELL);

                    ScPageBreakShell( ScTabViewShell* pView );
                    ~ScPageBreakShell();

};

#endif

<commit_msg>INTEGRATION: CWS calcwarnings (1.2.322); FILE MERGED 2006/12/14 17:57:13 nn 1.2.322.1: #i69284# warning-free: ui, unxsols4<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: pgbrksh.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: vg $ $Date: 2007-02-27 13:25:05 $
 *
 *  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 SC_PGBRKSH_HXX
#define SC_PGBRKSH_HXX

#ifndef _SFXMODULE_HXX //autogen
#include <sfx2/module.hxx>
#endif
#ifndef _SFX_SHELL_HXX //autogen
#include <sfx2/shell.hxx>
#endif

#include "shellids.hxx"

class ScTabViewShell;

class ScPageBreakShell : public SfxShell
{
public:
    TYPEINFO();
    SFX_DECL_INTERFACE(SCID_PAGEBREAK_SHELL)

                    ScPageBreakShell( ScTabViewShell* pView );
                    ~ScPageBreakShell();

};

#endif

<|endoftext|>


<commit_before>#pragma once

#include <QtGlobal>

#define CHATTERINO_VERSION "2.0.2"

#if defined(Q_OS_WIN)
#define CHATTERINO_OS "win"
#elif defined(Q_OS_MACOS)
#define CHATTERINO_OS "macos"
#elif defined(Q_OS_LINUX)
#define CHATTERINO_OS "linux"
#endif
<commit_msg>Increased version number to 2.0.3<commit_after>#pragma once

#include <QtGlobal>

#define CHATTERINO_VERSION "2.0.3"

#if defined(Q_OS_WIN)
#define CHATTERINO_OS "win"
#elif defined(Q_OS_MACOS)
#define CHATTERINO_OS "macos"
#elif defined(Q_OS_LINUX)
#define CHATTERINO_OS "linux"
#endif
<|endoftext|>