TriloBot Simulator (C++, Qt4, Flex, Readline, Boost)
File detail
Source code
/*
* Copyright (C) 2008 Jakub Filak <xfilak01@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 __SIMULATOR_H__
#define __SIMULATOR_H__
#include "physics.h"
#include <boost/shared_ptr.hpp>
/**
* Component state at time
*/
class State : public BaseMovingObject
{
public:
State( const std::string& id,
DateTime st,
double speed,
double tangle,
double size,
const struct Position& pos );
/**
* Component name
*/
const std::string& ComponentID() const;
/**
* Time when state was save
*/
const DateTime& Stamp() const;
virtual State* Clone();
virtual ~State();
protected:
virtual void ImplSerialize( std::ostream& );
virtual void ImplDeserialize( std::istream& );
virtual void StateSerialize( std::ostream& );
virtual void StateDeserialize( std::istream& );
private:
struct Members;
Members* pimpl;
};
typedef boost::shared_ptr<State> StatePtr;
/**
* Container for states
*/
class StateContainer
{
public:
StateContainer();
StatePtr Current(const DateTime& now);
StateContainer& Current( StatePtr );
StatePtr Next(const DateTime& now);
StateContainer& Next( StatePtr );
void Serialize( std::ostream& output );
void Deserialize( std::istream& input );
~StateContainer();
private:
static const std::string SER_START;
static const std::string SER_NEXT;
static const std::string SER_FINISH;
void UpdateStates( const DateTime& now );
struct Members;
Members* pimpl;
};
#endif