TriloBot Simulator (C++, Qt4, Flex, Readline, Boost)
File detail
Source code
/*
* Copyright (C) 2008 Kamil Dudka <xdudka00@stud.fit.vutbr.cz>
*
* This file is part of rob08
*
* rob08 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* rob08 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 rob08. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CORESYNC_H
#define CORESYNC_H
#include "config.h"
#include "core.h"
#include "scanner.h"
#ifndef BUILDING_DOX
# include <istream>
# include <QThread>
# include <string>
#endif
class CoreSync {
public:
CoreSync(ICore *);
~CoreSync();
void sync(const std::string &);
void lockForVis();
void unlockAfterVis();
protected:
ICore* getCore();
friend class LockedCore;
private:
struct Private;
Private *d;
};
class LockedCore {
public:
LockedCore(CoreSync *cs):
cs_(cs)
{
cs_->lockForVis();
}
~LockedCore() {
cs_->unlockAfterVis();
}
ICore* operator->() {
return cs_->getCore();
}
private:
LockedCore(const LockedCore &);
LockedCore& operator=(const LockedCore&);
CoreSync *cs_;
};
struct CoreInfo {
double x;
double y;
double angle;
double distance;
double speed;
double radius;
};
void readCoreInfo(LockedCore &, CoreInfo &);
class ICoreInfoSource {
public:
virtual ~ICoreInfoSource() { }
virtual const CoreInfo& coreInfo() const = 0;
};
class SyncReader: public QThread, public IErrorSensitive {
public:
SyncReader(std::istream &input, CoreSync *);
~SyncReader();
void syncExit();
bool hasError() const;
protected:
virtual void run();
private:
struct Private;
Private *d;
};
#endif /* CORESYNC_H */