Matrix.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *
00003  * Copyright (C) 2009-2011 Cassio Neri Moreira
00004  *
00005  * This file is part of the KeyValue library.
00006  *
00007  * The KeyValue library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as published
00009  * by the Free Software Foundation, either version 3 of the License, or (at
00010  * your option) any later version.
00011  *
00012  * The KeyValue library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
00015  * Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License along
00018  * with KeyValue. If not, see <http://www.gnu.org/licenses/>.
00019  *
00020  * If you modify this library, or any covered work, by linking or combining
00021  * it with Excel (or a modified version of that program), containing parts
00022  * covered by the terms of End-User License Agreement for Microsoft
00023  * Software, the licensors of KeyValue grant you additional permission to
00024  * convey the resulting work.
00025  *
00026  **************************************************************************/
00027 
00034 #ifndef KEYVALUE_VALUE_MATRIX_H_
00035 #define KEYVALUE_VALUE_MATRIX_H_
00036 
00037 #include <iosfwd>
00038 #include <boost/intrusive_ptr.hpp>
00039 
00040 #include "keyvalue/value/Variant.h"
00041 
00042 namespace keyvalue {
00043 namespace value {
00044 
00063 class Matrix {
00064 
00065 public:
00066 
00077   explicit
00078   Matrix(size_t nRows = 1, size_t nCols = 1);
00079 
00085   size_t
00086   getNRows() const;
00087 
00093   size_t
00094   getNCols() const;
00095 
00112    void
00113    resize(size_t nRows, size_t nCols);
00114 
00130   const Variant&
00131   operator()(size_t i, size_t j) const;
00132 
00136   Variant&
00137   operator()(size_t i, size_t j);
00138 
00158   bool
00159   operator==(const Matrix& rhs) const;
00160 
00161 protected:
00162 
00182   void
00183   transposeVector();
00184 
00185 private:
00186 
00194   struct Impl;
00195   ::boost::intrusive_ptr<Impl> pimpl_;
00196 
00197   friend void
00198   intrusive_ptr_add_ref(Matrix::Impl* pimpl);
00199 
00200   friend void
00201   intrusive_ptr_release(Matrix::Impl* pimpl);
00202 };
00203 
00213 void
00214 intrusive_ptr_add_ref(Matrix::Impl* pimpl);
00215 
00225 void
00226 intrusive_ptr_release(Matrix::Impl* pimpl);
00227 
00233 ::std::ostream&
00234 operator<<(::std::ostream& os, const Matrix& matrix);
00235 
00236 } // namespace value
00237 } // namespace keyvalue
00238 
00239 #endif // KEYVALUE_VALUE_MATRIX_H_