StartingPosition.cpp

Go to the documentation of this file.
00001 
00005 /* Copyright © 2010 James Legg.
00006     This program 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     (at your option) any later version.
00010 */
00011 
00012 #include "StartingPosition.h"
00013 #include "FormErrors.h"
00014 #include "Mesh/DrawableMesh.h"
00015 #include "Texture.h"
00016 
00017 #include <GL/gl.h>
00018 
00019 namespace Track
00020 {
00021 
00022 std::string StartingPosition::get_class_identifier() const
00023 {
00024     return std::string("Track::StartingPosition");
00025 }
00026 
00027 const unsigned int latest_starting_position_version = 1;
00028 
00029 StartingPosition::StartingPosition(std::istream & source)
00030     :   TrackAttachment(source)
00031 {
00032     unsigned int version;
00033     source >> version;
00034     if (version == 0) throw DepreciatedVersionError();
00035     if (version > latest_starting_position_version) throw NewVersionError();
00036     
00037     source >> m_rank;
00038 }
00039 
00040 StartingPosition::StartingPosition(unsigned int rank)
00041     :   m_rank(rank)
00042 {
00043 }
00044 
00045 StartingPosition::StartingPosition()
00046     :   m_rank(0)
00047 {
00048 }
00049 
00050 StartingPosition::~StartingPosition()
00051 {
00052 }
00053 
00054 void StartingPosition::draw() const
00055 {
00056     static DrawableMesh mesh("data/generic/start-marker");
00057     static Texture texture("data/generic/start-marker.png");
00058     texture.bind();
00059     mesh.draw();
00060 }
00061 
00062 void StartingPosition::add_data(std::ostream & stream) const
00063 {
00064     TrackAttachment::add_data(stream);
00065     stream << ' ' << (*this);
00066 }
00067 
00068 unsigned int StartingPosition::get_rank() const
00069 {
00070     return m_rank;
00071 }
00072 
00073 std::ostream & operator<<(std::ostream & destination, StartingPosition starting_position)
00074 {
00075     destination << latest_starting_position_version << ' '
00076                 << starting_position.get_rank();
00077     return destination;
00078 }
00079 
00080 } // namespace Track

Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:12 2010 by Doxygen version 1.4.7 for Racer version svn335.