00001 /**** 00002 ***** Copyright 2010 Intel Corporation All Rights Reserved. 00003 ***** 00004 ***** The source code, information and material contained herein are owned by Intel Corporation or its suppliers ***** 00005 ***** or licensors, and title to such Material remains with Intel Corporation or its suppliers or licensors. ***** 00006 ***** The Material contains proprietary information of Intel or its suppliers and licensors. The Material is ***** 00007 ***** protected by worldwide copyright laws and treaty provisions. No part of the Material may be used, copied, ***** 00008 ***** reproduced, modified, published, uploaded, posted, transmitted, distributed or disclosed in any way without ***** 00009 ***** Intel's prior express written permission. 00010 ***** 00011 ***** No license under any patent, copyright or other intellectual property rights in the material is granted to ***** 00012 ***** or conferred upon you, either expressly, by implication, inducement, estoppel or otherwise. Any license ***** 00013 ***** under such intellectual property rights must be express and approved by Intel in writing. 00014 ****/ 00015 00016 /**** Copyright Ends ****/ 00017 00018 #ifndef ARBB_CPP_NESTED_HPP 00019 #define ARBB_CPP_NESTED_HPP 00020 00021 #include <vector> 00022 #include "namespace.hpp" 00023 #include "dense.hpp" 00024 #include "detail/container.hpp" 00025 #include "detail/type_traits.hpp" 00026 00027 namespace ARBB_CPP_NS { 00028 00031 00035 template <typename T> 00036 class nested { 00037 00039 00040 typedef detail::container_element<T> element; 00041 00042 typedef typename detail::container_array<detail::is_scalar<T>::value ? 1 : detail::default_container_array_size> container_list; 00043 00045 00046 public: 00047 00049 typedef T element_type; 00050 00052 nested(); 00055 nested(const nested& other); 00060 template <typename U> 00061 nested(const nested<U>& other); 00062 00065 ~nested(); 00066 00067 static nested parse(const char* string); 00068 00071 nested& operator=(const nested& other); 00072 00075 dense<T, 1> flatten() const; 00077 dense<usize, 1> length(const usize& segment) const; 00079 dense<usize, 1> lengths() const; 00082 dense<usize, 1> offsets() const; 00086 dense<boolean, 1> flags() const; 00087 00088 dense<usize, 1> indices() const; 00089 00091 dense<T, 1> segment(const usize& i) const; 00092 00094 T operator()(const usize& i, const usize& j) const; 00095 00096 nested operator[](const nested<boolean>& mask) const; 00097 00099 00102 arbb_variable_t vm_variable(std::size_t index = 0) const; 00103 00104 typedef typename container_list::iterator container_iterator; 00105 typedef typename container_list::const_iterator container_const_iterator; 00106 00107 container_iterator containers_begin() { return m_members.begin(); } 00108 container_iterator containers_end() { return m_members.end(); } 00109 container_const_iterator containers_begin() const { return m_members.begin(); } 00110 container_const_iterator containers_end() const { return m_members.end(); } 00111 00113 00114 private: 00115 00117 00118 void init(); 00119 00120 template <typename U> 00121 void assign(const nested<U>& other); 00122 00123 template <typename U> 00124 void cast(const nested<U>& other); 00125 00126 container_list m_members; 00127 00129 }; 00130 00132 00134 00135 namespace detail { 00136 00137 template <typename T> 00138 struct container_traits<nested<T> > { 00139 enum { shape = 1 << 4 }; 00140 enum { is_container = 1 }; 00141 typedef T element_type; 00142 }; 00143 00144 } // namespace detail 00145 00147 00148 } // namespace ARBB_CPP_NS 00149 00150 #endif // ARBB_CPP_NESTED_HPP
Copyright © 2010, Intel Corporation. All rights reserved.