input_record_repeat.h
Go to the documentation of this file.
00001 /* This file is part of the Pangolin Project.
00002  * http://github.com/stevenlovegrove/Pangolin
00003  *
00004  * Copyright (c) 2011 Steven Lovegrove
00005  *
00006  * Permission is hereby granted, free of charge, to any person
00007  * obtaining a copy of this software and associated documentation
00008  * files (the "Software"), to deal in the Software without
00009  * restriction, including without limitation the rights to use,
00010  * copy, modify, merge, publish, distribute, sublicense, and/or sell
00011  * copies of the Software, and to permit persons to whom the
00012  * Software is furnished to do so, subject to the following
00013  * conditions:
00014  *
00015  * The above copyright notice and this permission notice shall be
00016  * included in all copies or substantial portions of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00019  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00020  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00021  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00022  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
00023  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00024  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00025  * OTHER DEALINGS IN THE SOFTWARE.
00026  */
00027 
00028 #ifndef PANGOLIN_INPUT_RECORD_REPEAT_H
00029 #define PANGOLIN_INPUT_RECORD_REPEAT_H
00030 
00031 #include "pangolin.h"
00032 
00033 #include <list>
00034 
00035 namespace pangolin
00036 {
00037 
00038 struct FrameInput
00039 {
00040     int index;
00041     std::string var;
00042     std::string val;
00043 };
00044 
00045 struct InputRecordRepeat
00046 {
00047     InputRecordRepeat(const std::string& var_record_prefix);
00048     ~InputRecordRepeat();
00049 
00050     void SetIndex(int id);
00051 
00052     void Record();
00053     void Stop();
00054 
00055     void LoadBuffer(const std::string& filename);
00056     void SaveBuffer(const std::string& filename);
00057     void ClearBuffer();
00058 
00059     void PlayBuffer();
00060     void PlayBuffer(int start, int end);
00061 
00062     void UpdateVariable(const std::string& name );
00063 
00064     template<typename T>
00065     inline void UpdateVariable(const Var<T>& var )
00066     {
00067         GuiVarChanged((void*)this, var.var->meta_full_name, *var.var);
00068     }
00069 
00070     int Size();
00071 
00072 protected:
00073     bool record;
00074     bool play;
00075 
00076     int index;
00077     std::ofstream file;
00078     std::string filename;
00079 
00080     std::list<FrameInput> play_queue;
00081     std::list<FrameInput> record_queue;
00082 
00083     static void GuiVarChanged(void* data, const std::string& name, _Var& var);
00084 };
00085 
00086 }
00087 
00088 #endif // PANGOLIN_INPUT_RECORD_REPEAT_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


pangolin_wrapper
Author(s): Todor Stoyanov
autogenerated on Wed Feb 13 2013 14:03:25