source: XIOS/dev/dev_olga/src/extern/blitz/include/blitz/update.h @ 1022

Last change on this file since 1022 was 1022, checked in by mhnguyen, 7 years ago
File size: 2.7 KB
RevLine 
[1022]1// -*- C++ -*-
2/***************************************************************************
3 * blitz/update.h      Declaration of the _bz_XXXX updater classes
4 *
5 * $Id$
6 *
7 * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
8 *
9 * This file is a part of Blitz.
10 *
11 * Blitz is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation, either version 3
14 * of the License, or (at your option) any later version.
15 *
16 * Blitz is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with Blitz.  If not, see <http://www.gnu.org/licenses/>.
23 *
24 * Suggestions:          blitz-devel@lists.sourceforge.net
25 * Bugs:                 blitz-support@lists.sourceforge.net   
26 *
27 * For more information, please see the Blitz++ Home Page:
28 *    https://sourceforge.net/projects/blitz/
29 *
30 ***************************************************************************/
31
32#ifndef BZ_UPDATE_H
33#define BZ_UPDATE_H
34
35#include <blitz/blitz.h>
36
37BZ_NAMESPACE(blitz)
38
39class _bz_updater_base { };
40
41#define BZ_DECL_UPDATER(name,op,symbol)                                 \
42  template<typename T_dest, typename T_source>                          \
43  class name : public _bz_updater_base {                                \
44  public:                                                               \
45  template<typename T1, typename T2> struct updateCast {                \
46    typedef name<T1, T2> T_updater;                                     \
47  };                                                                    \
48                                                                        \
49  static inline void update(T_dest& restrict x, T_source y)             \
50    { x op y; }                                                         \
51  static void prettyPrint(BZ_STD_SCOPE(string) &str)                    \
52    { str += symbol; }                                                  \
53  }
54
55template<typename T_dest, typename T_source>
56class _bz_update : public _bz_updater_base {
57  public:
58
59  /** Traits class used to get an updater with different types. */
60  template<typename T1, typename T2> struct updateCast {
61    typedef _bz_update<T1, T2> T_updater;
62  };
63
64    static inline void update(T_dest& restrict x, T_source y)
65  { x = /*(X)*/y; }
66
67    static void prettyPrint(BZ_STD_SCOPE(string) &str)
68    { str += "="; }
69};
70
71BZ_DECL_UPDATER(_bz_plus_update, +=, "+=");
72BZ_DECL_UPDATER(_bz_minus_update, -=, "-=");
73BZ_DECL_UPDATER(_bz_multiply_update, *=, "*=");
74BZ_DECL_UPDATER(_bz_divide_update, /=, "/=");
75BZ_DECL_UPDATER(_bz_mod_update, %=, "%=");
76BZ_DECL_UPDATER(_bz_xor_update, ^=, "^=");
77BZ_DECL_UPDATER(_bz_bitand_update, &=, "&=");
78BZ_DECL_UPDATER(_bz_bitor_update, |=, "|=");
79BZ_DECL_UPDATER(_bz_shiftl_update, <<=, "<<=");
80BZ_DECL_UPDATER(_bz_shiftr_update, >>=, ">>=");
81
82BZ_NAMESPACE_END
83
84#endif // BZ_UPDATE_H
85
Note: See TracBrowser for help on using the repository browser.