[Rcpp-commits] r1564 - in pkg/Rcpp/inst/include: . Rcpp Rcpp/sugar Rcpp/traits Rcpp/vector

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 17 13:13:02 CEST 2010


Author: romain
Date: 2010-06-17 13:13:02 +0200 (Thu, 17 Jun 2010)
New Revision: 1564

Added:
   pkg/Rcpp/inst/include/Rcpp/traits/get_iterator.h
Modified:
   pkg/Rcpp/inst/include/Rcpp/Vector.h
   pkg/Rcpp/inst/include/Rcpp/sugar/LogicalResult.h
   pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h
   pkg/Rcpp/inst/include/Rcpp/vector/get_iterator.h
   pkg/Rcpp/inst/include/RcppCommon.h
Log:
LogicalResult inherit from VectorBase

Modified: pkg/Rcpp/inst/include/Rcpp/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Vector.h	2010-06-17 09:50:56 UTC (rev 1563)
+++ pkg/Rcpp/inst/include/Rcpp/Vector.h	2010-06-17 11:13:02 UTC (rev 1564)
@@ -31,9 +31,6 @@
 
 namespace Rcpp{
 
-#include <Rcpp/vector/get_iterator.h>
-#include <Rcpp/vector/VectorBase.h>
-
 #include <Rcpp/vector/00_forward_Vector.h>
 #include <Rcpp/vector/00_forward_proxy.h>
 #include <Rcpp/vector/00_forward_eval_methods.h>

Modified: pkg/Rcpp/inst/include/Rcpp/sugar/LogicalResult.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/LogicalResult.h	2010-06-17 09:50:56 UTC (rev 1563)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/LogicalResult.h	2010-06-17 11:13:02 UTC (rev 1564)
@@ -26,7 +26,7 @@
 namespace sugar{  
 
 template <typename T>
-class LogicalResult {
+class LogicalResult : public Rcpp::VectorBase<LGLSXP,true,LogicalResult<T> > {
 public:
 	
 	LogicalResult() {} ;
@@ -124,7 +124,16 @@
 	
 } ;
 
+} // namespace sugar
+
+namespace traits{
+	template <typename T>
+	struct get_iterator	< Rcpp::sugar::LogicalResult<T> >{
+		typedef typename Rcpp::sugar::LogicalResult<T>::iterator type ;
+	} ;
+	
+} // namespace traits
+
 }
-}
 
 #endif

Added: pkg/Rcpp/inst/include/Rcpp/traits/get_iterator.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/get_iterator.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/traits/get_iterator.h	2010-06-17 11:13:02 UTC (rev 1564)
@@ -0,0 +1,36 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+//
+// get_iterator.h: Rcpp R/C++ interface class library -- 
+//
+// Copyright (C) 2010	Dirk Eddelbuettel and Romain Francois
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef Rcpp__traits__get_iterator_h
+#define Rcpp__traits__get_iterator_h
+
+namespace Rcpp{
+namespace traits{
+
+	template <typename T>
+	struct get_iterator{
+		typedef typename T::iterator type ;
+	} ;
+	
+}  // traits
+}  // Rcpp
+
+#endif

Modified: pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h	2010-06-17 09:50:56 UTC (rev 1563)
+++ pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h	2010-06-17 11:13:02 UTC (rev 1564)
@@ -22,25 +22,30 @@
 #ifndef Rcpp__vector__VectorBase_h
 #define Rcpp__vector__VectorBase_h
 
+namespace Rcpp{
+	
 /** a base class for vectors, modelled after the CRTP */
 template <int RTYPE, bool na, typename VECTOR>
 class VectorBase {
 public:
 	struct r_type : traits::integral_constant<int,RTYPE>{} ;
 	struct can_have_na : traits::integral_constant<bool,na>{} ;
-	
-	typedef typename traits::get_iterator<VECTOR>::type iterator ;
 	typedef typename traits::storage_type<RTYPE>::type stored_type ;
 	
 	VECTOR& get_ref(){
 		return static_cast<VECTOR&>(*this) ;
 	}
-	inline iterator begin(){ return static_cast<VECTOR*>(this)->begin() ; }
-	inline iterator end(){ return static_cast<VECTOR*>(this)->end() ; }
+	
+	// FIXME (or not): cannot get the iterator stuff to work
+	//                 we can probaly live without
+	// typedef typename traits::get_iterator<VECTOR>::type iterator ;
+	// inline iterator begin(){ return static_cast<VECTOR*>(this)->begin() ; }
+	// inline iterator end(){ return static_cast<VECTOR*>(this)->end() ; }
 
 	inline stored_type operator[]( int i) const { return static_cast<VECTOR*>(this)->operator[](i) ; }
 	
 	inline int size() const { return static_cast<VECTOR*>(this)->size() ; }
 } ;
 
+} // namespace Rcpp
 #endif

Modified: pkg/Rcpp/inst/include/Rcpp/vector/get_iterator.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/get_iterator.h	2010-06-17 09:50:56 UTC (rev 1563)
+++ pkg/Rcpp/inst/include/Rcpp/vector/get_iterator.h	2010-06-17 11:13:02 UTC (rev 1564)
@@ -22,13 +22,4 @@
 #ifndef Rcpp__vector__get_iterator_h
 #define Rcpp__vector__get_iterator_h
 
-namespace traits{
-
-	template <typename T>
-	struct get_iterator{
-		typedef typename T::iterator type ;
-	} ;
-	
-}  // internal
-
 #endif

Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h	2010-06-17 09:50:56 UTC (rev 1563)
+++ pkg/Rcpp/inst/include/RcppCommon.h	2010-06-17 11:13:02 UTC (rev 1564)
@@ -226,6 +226,7 @@
 #include <Rcpp/traits/is_na.h>
 #include <Rcpp/traits/is_trivial.h>
 #include <Rcpp/traits/init_type.h>
+#include <Rcpp/traits/get_iterator.h>
 
 #include <Rcpp/traits/is_const.h>
 #include <Rcpp/traits/is_reference.h>
@@ -252,6 +253,20 @@
 #include <Rcpp/preprocessor.h>
 #include <Rcpp/algo.h>
 
+
+// namespace Rcpp{
+// namespace sugar{
+// template <typename T> class LogicalResult ;
+// }
+// 
+// namespace traits{
+// 	template <typename T>
+// 	struct get_iterator	< Rcpp::sugar::LogicalResult<T> > ;
+// }
+// }
+
+#include <Rcpp/vector/VectorBase.h>
+
 #include <Rcpp/sugar/sugar_forward.h>
 
 #endif



More information about the Rcpp-commits mailing list