TrackAttachment.cpp

Go to the documentation of this file.
00001 
00005 /* Copyright © 2009, 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 "TrackAttachment.h"
00013 #include "FormErrors.h"
00014 
00015 namespace Track
00016 {
00017 
00018 std::string TrackAttachment::get_class_identifier() const
00019 {
00020     return std::string ("Track::TrackAttachment");;
00021 }
00022 
00023 const unsigned int latest_track_attachment_file_version = 2;
00024 
00025 TrackAttachment::TrackAttachment(std::istream & source)
00026 {
00027     unsigned int version;
00028     source >> version;
00029     if (version == 1)
00030     {
00031         m_vertical_position = 0;
00032     }
00033     else if (version < latest_track_attachment_file_version)
00034     {
00035         throw DepreciatedVersionError();
00036     }
00037     else if (version > latest_track_attachment_file_version)
00038     {
00039         throw NewVersionError();
00040     }
00041     source >> m_t_position;
00042     source >> m_lateral_position;
00043     if (version > 1)
00044     {
00045         source >> m_vertical_position;
00046     }
00047 }
00048 
00049 TrackAttachment::TrackAttachment()
00050     :   m_t_position(0)
00051     ,   m_lateral_position(0)
00052     ,   m_vertical_position(0)
00053 {
00054 }
00055 
00056 TrackAttachment::~TrackAttachment()
00057 {
00058 }
00059 
00060 btScalar TrackAttachment::get_t_position() const
00061 {
00062     return m_t_position;
00063 }
00064 
00065 void TrackAttachment::set_t_position(btScalar value)
00066 {
00067     m_t_position = value;
00068 }
00069 
00070 btScalar TrackAttachment::get_lateral_position() const
00071 {
00072     return m_lateral_position;
00073 }
00074 
00075 void TrackAttachment::set_lateral_position(btScalar value)
00076 {
00077     m_lateral_position = value;
00078 }
00079 
00080 btScalar TrackAttachment::get_vertical_position() const
00081 {
00082     return m_vertical_position;
00083 }
00084 
00085 void TrackAttachment::set_vertical_position(btScalar value)
00086 {
00087     m_vertical_position = value;
00088 }
00089 
00090 void TrackAttachment::add_data(std::ostream & destination) const
00091 {
00092     destination << latest_track_attachment_file_version << " "
00093                 << m_t_position << " "
00094                 << m_lateral_position << " "
00095                 << m_vertical_position;
00096 }
00097 
00098 void TrackAttachment::draw() const
00099 {
00100 }
00101 
00102 void TrackAttachment::set_global_transform(btTransform tansform)
00103 {
00104     m_global_transform = tansform;
00105 }
00106 
00107 const btTransform & TrackAttachment::get_global_transform() const
00108 {
00109     return m_global_transform;
00110 }
00111 
00112 std::ostream & operator<<(std::ostream & destination, const TrackAttachment & attachment)
00113 {
00114     attachment.add_data(destination);
00115 }
00116 
00117 
00118 } // 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.