Created
          October 25, 2012 09:00 
        
      - 
      
- 
        Save mgronhol/3951518 to your computer and use it in GitHub Desktop. 
    Tipsy Treeshrew, plan.hh
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Luokat: | |
| /* | |
| create_key( y, x, version, is_current ) | |
| y << 32 | x << 12 | is_current << 10 | version | |
| */ | |
| uint64_t create_key( uint32_t y, uint32_t x, uint16_t version, bool is_current ); | |
| uint32_t get_row( uint64_t key ); | |
| uint32_t get_column( uint64_t key ); | |
| uint16_t get_version( uint64_t key ); | |
| bool get_is_current( uint64_t key ); | |
| /* | |
| Value | |
| getRaw | |
| asString | |
| asInteger | |
| asDouble | |
| */ | |
| enum ValueType {....}; | |
| class Value { | |
| virtual std::string getRaw(); | |
| virtual std::string asString(); | |
| virtual int64_t asInteger(); | |
| virtual double asDouble(); | |
| virtual ValueType getType(); | |
| } | |
| // IntegerValue, StringValue, DoubleValue, NullValue, ScriptValue | |
| class IntegerValue: public Value {...} | |
| class StringValue: public Value {...} | |
| class DoubleValue: public Value {...} | |
| class NullValue: public Value {...} | |
| class ScriptValue: public Value {...} | |
| /* | |
| Sheet | |
| read( y, x, version ) | |
| write( y, x, value ) | |
| clear( y, x ) | |
| get_cells() | |
| std::map< uint64_t, Value > cells; | |
| std::set< uint64_t > rows_index; | |
| */ | |
| class Sheet { | |
| Value read( uint32_t row, uint32_t column, uint16_t version = 0 ); | |
| void write( uint32_t row, uint32_t column, Value value ); | |
| void clear( uint32_t row, uint32_t column ); | |
| std::vector< uint64_t > get_cells(); | |
| private: | |
| std::map< uint64_t, Value > cells; | |
| std::set< uint64_t > rows_index; | |
| } | |
| /* | |
| Range | |
| is_in | |
| ColumnRange, RowRange, SingleRange, FullRange | |
| **/ | |
| class Range { | |
| virtual bool is_in( uint32_t row, uint32_t column ); | |
| } | |
| class ColumnRange : public Range {...} | |
| class RowRange : public Range {...} | |
| class SingleRange : public Range {...} | |
| class FullRange : public Range {...} | |
| /* | |
| Selection | |
| add_range | |
| is_in | |
| get_next_row( y, x ) | |
| get_next_column( y, x ) | |
| get_next( y, x ) | |
| */ | |
| class Selection { | |
| void add_range( Range ); | |
| bool is_in( uint32_t row, uint32_t column ); | |
| std::pair< uint32_t, uint32_t > get_next_row( uint32_t row, uint32_t column ); | |
| std::pair< uint32_t, uint32_t > get_next_column( uint32_t row, uint32_t column ); | |
| std::pair< uint32_t, uint32_t > get_next( uint32_t row, uint32_t column ); | |
| } | |
| /* | |
| SheetAccessor | |
| SheetAccessor( sheet, selection ) | |
| read( y, x, translated, version ) | |
| write( y, x, value, translated ) | |
| get_next_row( y, x ) | |
| get_next_column( y, x ) | |
| get_next( y, x ) | |
| */ | |
| class SheetAccessor { | |
| SheetAccessor( Sheet&, Selection& ); | |
| Value read( uint32_t row, uint32_t column, bool uniform, uint16_t version = 0 ); | |
| bool write( uint32_t row, uint32_t column, Value value, bool uniform ); | |
| std::pair< uint32_t, uint32_t > get_next_row( uint32_t row, uint32_t column ); | |
| std::pair< uint32_t, uint32_t > get_next_column( uint32_t row, uint32_t column ); | |
| std::pair< uint32_t, uint32_t > get_next( uint32_t row, uint32_t column ); | |
| } | |
| /* | |
| Plotter | |
| plot( sheet_accessor, std::map<std::string, Value> params ) | |
| GnuplotPlotter | |
| */ | |
| class Plotter { | |
| virtual bool plot( SheetAccessor&, std::map<std::string, Value> params ); | |
| } | |
| class GnuplotPlotter : public Plotter; | |
| /* | |
| SymbolTable | |
| std::map<std::string, Value> | |
| */ | |
| class SymbolTable { | |
| void set( std::string key, Value value ); | |
| Value get( std::string key ); | |
| private: | |
| std::map<std::string, Value> table; | |
| } | |
| /* | |
| Spreadsheet | |
| std::map<std::string, Sheet> sheets; | |
| */ | |
| class Spreadsheet { | |
| Sheet& spawn_sheet( std::string name ); | |
| Sheet& get_sheet( std::string name ); | |
| bool remove_sheet( std::string name ); | |
| std::vector<std::string> get_sheets(); | |
| private: | |
| std::map<std::string, Sheet> sheets; | |
| } | |
| /* | |
| Serialiser | |
| toString() | |
| CsvSerialiser, MultiSheetSerialiser, TemplateSerialiser | |
| */ | |
| class Serialiser { | |
| virtual Serialiser( Spreadsheet& ); | |
| virtual std::string toString(); | |
| } | |
| class CsvSerialiser : public Serialiser {...} | |
| class MultiSheetSeriliser : public Serialiser {...} | |
| class TemplateSerialiser : public Serialiser {...} | |
| /* | |
| Deserialiser | |
| fromString( std::string ) | |
| CsvDeserialiser, MutliSheetDeserialiser, AccessLogDeserialiser | |
| */ | |
| class Deserialiser { | |
| virtual Deserialiser( Spreadsheet& ); | |
| virtual bool fromString( std::string ); | |
| } | |
| class CsvDeserialiser : public Deserialiser {...} | |
| class MultiSheetDeserialiser : public Deserialiser {...} | |
| class AccessLogDeserialiser : public Deserialiser {...} | |
| /* | |
| ScriptEngine (lua) | |
| ScriptEngine( Spreadsheet&, SymbolTable& ) | |
| run( Value ) | |
| */ | |
| class ScriptEngine { | |
| ScriptEngine( Spreadsheet&, SymbolTable& ); | |
| Value run( Value ); | |
| } | |
| /* | |
| InterfaceEngine (singleton) | |
| set_sheet( sheet ) | |
| set_selection( selection ) | |
| set_offset( offset ) | |
| draw_sheet() | |
| print_message( type, content ) | |
| flash() | |
| menu( std::vector< std::pair<std::string, size_t> > options ) | |
| editor( std::string content, size_t size ) | |
| get_command() | |
| */ | |
| /* | |
| class InterfaceEngine { | |
| void set_sheet( Sheet& ); | |
| menu( std::vector< std::pair<std::string, size_t> > options ) | |
| editor( std::string content, size_t size ) | |
| get_command() | |
| */ | |
| enum MessageType {...}; | |
| enum EditorSize {...}; | |
| class InterfaceEngine { | |
| void set_sheet( Sheet& ); | |
| void set_selection( Selection& ); | |
| void set_offset( uint32_t row, uint32_t column ); | |
| void draw_sheet(); | |
| void print_message( MessageType type, std::string content ); | |
| void flash(); | |
| int32_t menu( std::vector< std::pair<std::string, int32_t> > options ); | |
| std::string editor( std::string content, EditorSize size ); | |
| std::string get_command(); | |
| } | |
| /* | |
| CommandEngine | |
| CommandEngine( SymbolTable& ) | |
| run() | |
| run_command( std::string ) | |
| */ | |
| class CommandEngine { | |
| CommandEngine( std::map<std::string, Spreadsheet>& spreadsheets, SymbolTable& symbols ); | |
| void run(); | |
| void execute_command( std::string cmd ); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment