coresync.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008 Kamil Dudka <xdudka00@stud.fit.vutbr.cz>
00003  *
00004  * This file is part of rob08
00005  *
00006  * rob08 is free software: you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation, either version 3 of the License, or
00009  * any later version.
00010  *
00011  * rob08 is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with rob08.  If not, see <http://www.gnu.org/licenses/>.
00018  */
00019 
00020 #ifndef CORESYNC_H
00021 #define CORESYNC_H
00022 
00023 #include "config.h"
00024 #include "core.h"
00025 #include "scanner.h"
00026 
00027 #ifndef BUILDING_DOX
00028 #   include <istream>
00029 #   include <QThread>
00030 #   include <string>
00031 #endif
00032 
00033 class CoreSync {
00034     public:
00035         CoreSync(ICore *);
00036         ~CoreSync();
00037         void sync(const std::string &);
00038         void lockForVis();
00039         void unlockAfterVis();
00040     protected:
00041         ICore* getCore();
00042         friend class LockedCore;
00043     private:
00044         struct Private;
00045         Private *d;
00046 };
00047 
00048 class LockedCore {
00049     public:
00050         LockedCore(CoreSync *cs):
00051             cs_(cs)
00052         {
00053             cs_->lockForVis();
00054         }
00055         ~LockedCore() {
00056             cs_->unlockAfterVis();
00057         }
00058         ICore* operator->() {
00059             return cs_->getCore();
00060         }
00061     private:
00062         LockedCore(const LockedCore &);
00063         LockedCore& operator=(const LockedCore&);
00064         CoreSync    *cs_;
00065 };
00066 
00067 struct CoreInfo {
00068     double x;
00069     double y;
00070     double angle;
00071     double distance;
00072     double speed;
00073     double radius;
00074 };
00075 void readCoreInfo(LockedCore &, CoreInfo &);
00076 
00077 class ICoreInfoSource {
00078     public:
00079         virtual ~ICoreInfoSource() { }
00080         virtual const CoreInfo& coreInfo() const = 0;
00081 };
00082 
00083 class SyncReader: public QThread, public IErrorSensitive {
00084     public:
00085         SyncReader(std::istream &input, CoreSync *);
00086         ~SyncReader();
00087         void syncExit();
00088         bool hasError() const;
00089     protected:
00090         virtual void run();
00091     private:
00092         struct Private;
00093         Private *d;
00094 };
00095 
00096 #endif /* CORESYNC_H */

Generated on Fri Jul 10 22:42:01 2009 for rob08 by  doxygen 1.5.4