00001 // Copyright (C) 2001 Petter Urkedal (petter.urkedal@matfys.lth.se) 00002 // 00003 // This file is free software; you can redistribute it and/or modify 00004 // it under the terms of the GNU General Public License as published by 00005 // the Free Software Foundation; either version 2 of the License, or 00006 // (at your option) any later version. 00007 // 00008 // This file is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 // GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License 00014 // along with this program; if not, write to the Free Software 00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software library without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to 00021 // produce an executable, this file does not by itself cause the 00022 // resulting executable to be covered by the GNU General Public 00023 // License. This exception does not however invalidate any other 00024 // reasons why the executable file might be covered by the GNU General 00025 // Public License. 00026 // 00027 // $Id: partial_ordering_product.h,v 1.1 2002/05/30 18:01:37 petter_urkedal Exp $ 00028 00029 #ifndef MORE_GEN_PARTIAL_ORDERING_PRODUCT_H 00030 #define MORE_GEN_PARTIAL_ORDERING_PRODUCT_H 00031 00032 #include <more/gen/partial_ordering.h> 00033 00034 namespace more { 00035 namespace gen { 00036 00037 template< typename T, template <typename> class Container = std::vector > 00038 struct partial_ordering_product { 00039 private: // XXX 00040 typedef more::partial_ordering<T> component_partial_ordering; 00041 typedef typename partial_ordering_type::element component_element; 00042 public: 00043 explicit partial_ordering_product(partial_ordering* o) 00044 : m_ordering(o) {} 00045 00046 struct element { 00047 typedef Container<T> value_type; 00048 typedef value_type& reference; 00049 typedef value_type* pointer; 00050 reference operator*() { update_value(); return *value; } 00051 pointer operator->() { update_value(); return value; } 00052 private: 00053 00054 Container<component_type> v; 00055 value_type* value; 00056 }; 00057 00058 private: 00059 partial_ordering<T>* m_ordering; 00060 }; 00061 00062 }} // more::gen 00063 00064 #endif