|
| 1 | +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- |
| 2 | +// |
| 3 | +// meat.h: Rcpp R/C++ interface class library -- |
| 4 | +// |
| 5 | +// Copyright (C) 2014 Dirk Eddelbuettel, Romain Francois, and Kevin Ushey |
| 6 | +// |
| 7 | +// This file is part of Rcpp. |
| 8 | +// |
| 9 | +// Rcpp is free software: you can redistribute it and/or modify it |
| 10 | +// under the terms of the GNU General Public License as published by |
| 11 | +// the Free Software Foundation, either version 2 of the License, or |
| 12 | +// (at your option) any later version. |
| 13 | +// |
| 14 | +// Rcpp is distributed in the hope that it will be useful, but |
| 15 | +// WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | +// GNU General Public License for more details. |
| 18 | +// |
| 19 | +// You should have received a copy of the GNU General Public License |
| 20 | +// along with Rcpp. If not, see <http://www.gnu.org/licenses/>. |
| 21 | +#ifndef RCPP_API_MEAT_PROXY_H |
| 22 | +#define RCPP_API_MEAT_PROXY_H |
| 23 | + |
| 24 | +namespace Rcpp { |
| 25 | + |
| 26 | + // Attribute Proxies |
| 27 | + template <typename CLASS> |
| 28 | + template <typename T> |
| 29 | + typename AttributeProxyPolicy<CLASS>::AttributeProxy& |
| 30 | + AttributeProxyPolicy<CLASS>::AttributeProxy::operator=(const T& rhs) { |
| 31 | + set( wrap(rhs) ); |
| 32 | + return *this; |
| 33 | + } |
| 34 | + |
| 35 | + template <typename CLASS> |
| 36 | + template <typename T> |
| 37 | + AttributeProxyPolicy<CLASS>::AttributeProxy::operator T() const { |
| 38 | + return as<T>(get()); |
| 39 | + } |
| 40 | + |
| 41 | + template <typename CLASS> |
| 42 | + AttributeProxyPolicy<CLASS>::AttributeProxy::operator SEXP() const { |
| 43 | + return get(); |
| 44 | + } |
| 45 | + |
| 46 | + template <typename CLASS> |
| 47 | + template <typename T> |
| 48 | + AttributeProxyPolicy<CLASS>::const_AttributeProxy::operator T() const { |
| 49 | + return as<T>(get()); |
| 50 | + } |
| 51 | + |
| 52 | + template <typename CLASS> |
| 53 | + AttributeProxyPolicy<CLASS>::const_AttributeProxy::operator SEXP() const { |
| 54 | + return get(); |
| 55 | + } |
| 56 | + |
| 57 | + // Names proxy |
| 58 | + |
| 59 | + template <typename CLASS> |
| 60 | + template <typename T> |
| 61 | + typename NamesProxyPolicy<CLASS>::NamesProxy& |
| 62 | + NamesProxyPolicy<CLASS>::NamesProxy::operator=(const T& rhs) { |
| 63 | + set( wrap(rhs) ); |
| 64 | + return *this; |
| 65 | + } |
| 66 | + |
| 67 | + template <typename CLASS> |
| 68 | + template <typename T> |
| 69 | + NamesProxyPolicy<CLASS>::NamesProxy::operator T() const { |
| 70 | + return as<T>( get() ); |
| 71 | + } |
| 72 | + |
| 73 | + template <typename CLASS> |
| 74 | + template <typename T> |
| 75 | + NamesProxyPolicy<CLASS>::const_NamesProxy::operator T() const { |
| 76 | + return as<T>( get() ); |
| 77 | + } |
| 78 | + |
| 79 | + // Slot proxy |
| 80 | + |
| 81 | + template <typename CLASS> |
| 82 | + template <typename T> |
| 83 | + typename SlotProxyPolicy<CLASS>::SlotProxy& |
| 84 | + SlotProxyPolicy<CLASS>::SlotProxy::operator=(const T& rhs) { |
| 85 | + set(wrap(rhs)); |
| 86 | + return *this; |
| 87 | + } |
| 88 | + |
| 89 | + template <typename CLASS> |
| 90 | + template <typename T> |
| 91 | + SlotProxyPolicy<CLASS>::SlotProxy::operator T() const { |
| 92 | + return as<T>(get()); |
| 93 | + } |
| 94 | + |
| 95 | + // Tag proxy |
| 96 | + |
| 97 | + template <typename CLASS> |
| 98 | + template <typename T> |
| 99 | + typename TagProxyPolicy<CLASS>::TagProxy& |
| 100 | + TagProxyPolicy<CLASS>::TagProxy::operator=(const T& rhs) { |
| 101 | + set( wrap(rhs) ); |
| 102 | + return *this; |
| 103 | + } |
| 104 | + |
| 105 | + template <typename CLASS> |
| 106 | + template <typename T> |
| 107 | + TagProxyPolicy<CLASS>::TagProxy::operator T() const { |
| 108 | + return as<T>(get()); |
| 109 | + } |
| 110 | + |
| 111 | + template <typename CLASS> |
| 112 | + TagProxyPolicy<CLASS>::TagProxy::operator SEXP() const { |
| 113 | + return get(); |
| 114 | + } |
| 115 | + |
| 116 | + template <typename CLASS> |
| 117 | + template <typename T> |
| 118 | + TagProxyPolicy<CLASS>::const_TagProxy::operator T() const { |
| 119 | + return as<T>(get()); |
| 120 | + } |
| 121 | + |
| 122 | + template <typename CLASS> |
| 123 | + TagProxyPolicy<CLASS>::const_TagProxy::operator SEXP() const { |
| 124 | + return get(); |
| 125 | + } |
| 126 | + |
| 127 | + // Environment Binding |
| 128 | + |
| 129 | + template <typename CLASS> |
| 130 | + template <typename T> |
| 131 | + typename BindingPolicy<CLASS>::Binding& |
| 132 | + BindingPolicy<CLASS>::Binding::operator=(const T& rhs) { |
| 133 | + set(wrap(rhs)); |
| 134 | + return *this; |
| 135 | + } |
| 136 | + |
| 137 | + template <typename CLASS> |
| 138 | + template <typename T> |
| 139 | + BindingPolicy<CLASS>::Binding::operator T() const { |
| 140 | + return as<T>(get()); |
| 141 | + } |
| 142 | + |
| 143 | + template <typename CLASS> |
| 144 | + template <typename T> |
| 145 | + BindingPolicy<CLASS>::const_Binding::operator T() const { |
| 146 | + return as<T>(get()); |
| 147 | + } |
| 148 | +} |
| 149 | + |
| 150 | +#endif |
0 commit comments