foursome.hpp

    1: #ifndef FOURSOME_HPP
    2: #define FOURSOME_HPP
    3: /*------------------------------------------------------------------------------
    4: 
    5:   Author:    Andy Rushton, from an original by Dan Milton
    6:   Copyright: (c) Southampton University 1999-2004
    7:              (c) Andy Rushton           2004-2009
    8:   License:   BSD License, see ../docs/license.html
    9: 
   10:   The next in the series pair->triple->foursome
   11: 
   12:   Originally called quadruple but that clashed (as did quad) with system
   13:   libraries on some operating systems
   14: 
   15:   ------------------------------------------------------------------------------*/
   16: 
   17: #include "os_fixes.hpp"
   18: #include "persistent.hpp"
   19: 
   20: ////////////////////////////////////////////////////////////////////////////////
   21: // the foursome class
   22: 
   23: template<typename T1, typename T2, typename T3, typename T4>
   24: struct foursome
   25: {
   26:   typedef T1 first_type;
   27:   typedef T2 second_type;
   28:   typedef T3 third_type;
   29:   typedef T4 fourth_type;
   30: 
   31:   T1 first;
   32:   T2 second;
   33:   T3 third;
   34:   T4 fourth;
   35: 
   36:   foursome(void);
   37:   foursome(const T1& p1, const T2& p2, const T3& p3, const T4& p4);
   38:   foursome(const foursome<T1,T2,T3,T4>& t2);
   39: };
   40: 
   41: ////////////////////////////////////////////////////////////////////////////////
   42: // creation
   43: 
   44: template<typename T1, typename T2, typename T3, typename T4>
   45: foursome<T1,T2,T3,T4> make_foursome(const T1& first, const T2& second, const T3& third, const T4& fourth);
   46: 
   47: ////////////////////////////////////////////////////////////////////////////////
   48: // comparison
   49: 
   50: template<typename T1, typename T2, typename T3, typename T4>
   51: bool operator == (const foursome<T1,T2,T3,T4>& left, const foursome<T1,T2,T3,T4>& right);
   52: 
   53: template<typename T1, typename T2, typename T3, typename T4>
   54: bool operator < (const foursome<T1,T2,T3,T4>& left, const foursome<T1,T2,T3,T4>& right);
   55: 
   56: ////////////////////////////////////////////////////////////////////////////////
   57: // string utilities
   58: 
   59: template<typename T1, typename T2, typename T3, typename T4>
   60: std::string foursome_to_string(const foursome<T1,T2,T3,T4>& values, const std::string& separator);
   61: 
   62: template<typename T1, typename T2, typename T3, typename T4>
   63: otext& print_foursome(otext& str, const foursome<T1,T2,T3,T4>& values, const std::string& separator);
   64: 
   65: template<typename T1, typename T2, typename T3, typename T4>
   66: otext& print_foursome(otext& str, const foursome<T1,T2,T3,T4>& values, const std::string& separator, unsigned indent);
   67: 
   68: ////////////////////////////////////////////////////////////////////////////////
   69: // data persistence
   70: 
   71: template<typename T1, typename T2, typename T3, typename T4>
   72: void dump_foursome(dump_context& str, const foursome<T1,T2,T3,T4>& data) throw(persistent_dump_failed);
   73: 
   74: template<typename T1, typename T2, typename T3, typename T4>
   75: void restore_foursome(restore_context& str, foursome<T1,T2,T3,T4>& data) throw(persistent_restore_failed);
   76: 
   77: ////////////////////////////////////////////////////////////////////////////////
   78: #include "foursome.tpp"
   79: #endif