New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
array.hpp in vendors/XIOS/current/src – NEMO

source: vendors/XIOS/current/src/array.hpp @ 3428

Last change on this file since 3428 was 3428, checked in by rblod, 12 years ago

importing initial XIOS vendor drop

File size: 3.0 KB
Line 
1#ifndef __XMLIO_CArray__
2#define __XMLIO_CArray__
3
4/// boost headers ///
5#include <boost/cstdint.hpp>
6#include <boost/shared_ptr.hpp>
7#include <boost/multi_array.hpp>
8
9/// xios headers ///
10#include "xmlioserver_spl.hpp"
11#include "buffer_in.hpp"
12#include "buffer_out.hpp"
13
14
15namespace xios
16{
17   template<size_t numDims>
18   inline detail::multi_array::extent_gen<numDims> getExtentNull(void) { return getExtentNull<numDims-1>()[0];}
19   
20   template<>
21   inline detail::multi_array::extent_gen<1> getExtentNull<1>(void) { return extents[0]; }
22
23   /// ////////////////////// Déclarations ////////////////////// ///
24   
25   template <typename ValueType, StdSize  NumDims, typename Allocator = std::allocator<ValueType> >
26   class CArray : public boost::multi_array<ValueType, NumDims, Allocator>
27   {
28         /// Définition de type ///
29         typedef boost::multi_array<ValueType, NumDims, Allocator> SuperClass;
30
31      public:
32
33         typedef ValueType ValType;
34
35         /// Constructeurs ///
36//         template <typename ExtentList>
37//            explicit CArray(const ExtentList & sizes);
38      template <typename ExtentList> CArray(const ExtentList & sizes)
39            : boost::multi_array<ValueType, NumDims, Allocator>
40                  (sizes, boost::fortran_storage_order())
41   { /* Ne rien faire de plus */ }
42
43
44         explicit CArray();
45
46//         template <typename ExtentList>
47//            CArray(const ExtentList & sizes, const boost::general_storage_order<NumDims> & store);
48      template <typename ExtentList>  CArray(const ExtentList & sizes, const boost::general_storage_order<NumDims> & store)
49               : boost::multi_array<ValueType, NumDims, Allocator> (sizes, store)
50   { /* Ne rien faire de plus */ }
51
52         CArray(const CArray & array);       // NEVER IMPLEMENTED.
53         CArray(const CArray * const array); // NEVER IMPLEMENTED.
54
55      public:
56
57         /// Flux ///
58         template <typename U, StdSize V, typename W>
59            friend StdOStream & operator << 
60                  (StdOStream & os, const CArray<U, V, W> & array);
61
62         template <typename U, StdSize V, typename W>
63            friend StdIStream & operator >> 
64                  (StdIStream & is, CArray<U, V, W> & array);
65
66      public:
67
68         void toBinary  (StdOStream & os) const;
69         void fromBinary(StdIStream & is);
70
71         size_t getSize(void) const ;
72         bool toBuffer  (CBufferOut& buffer) const;
73         bool fromBuffer(CBufferIn& buffer);
74
75
76         /// Destructeur ///
77         virtual ~CArray(void);
78
79   }; // class CArray
80
81   ///---------------------------------------------------------------
82
83} // namespace xios
84
85//#include "array_impl.hpp"
86#include "array_mac.hpp"
87namespace xios
88{
89   template <typename ValueType> void FromBinary(StdIStream & is, ARRAY(ValueType, 1) & array) ;
90   template <typename ValueType> void FromBinary(StdIStream & is, ARRAY(ValueType, 2) & array) ;
91   template <typename ValueType> void FromBinary(StdIStream & is, ARRAY(ValueType, 3) & array) ;
92}
93#endif // __XMLIO_CArray__
Note: See TracBrowser for help on using the repository browser.