1 | // -*- C++ -*- |
---|
2 | /*************************************************************************** |
---|
3 | * blitz/update.h Declaration of the _bz_XXXX updater classes |
---|
4 | * |
---|
5 | * $Id: update.h,v 1.5 2004/03/09 21:55:31 julianc Exp $ |
---|
6 | * |
---|
7 | * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org> |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but 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 | * Suggestions: blitz-dev@oonumerics.org |
---|
20 | * Bugs: blitz-bugs@oonumerics.org |
---|
21 | * |
---|
22 | * For more information, please see the Blitz++ Home Page: |
---|
23 | * http://oonumerics.org/blitz/ |
---|
24 | * |
---|
25 | ***************************************************************************/ |
---|
26 | |
---|
27 | #ifndef BZ_UPDATE_H |
---|
28 | #define BZ_UPDATE_H |
---|
29 | |
---|
30 | #include <blitz/blitz.h> |
---|
31 | |
---|
32 | BZ_NAMESPACE(blitz) |
---|
33 | |
---|
34 | class _bz_updater_base { }; |
---|
35 | |
---|
36 | #define BZ_DECL_UPDATER(name,op,symbol) \ |
---|
37 | template<typename X, typename Y> \ |
---|
38 | class name : public _bz_updater_base { \ |
---|
39 | public: \ |
---|
40 | static inline void update(X& restrict x, Y y) \ |
---|
41 | { x op y; } \ |
---|
42 | static void prettyPrint(BZ_STD_SCOPE(string) &str) \ |
---|
43 | { str += symbol; } \ |
---|
44 | } |
---|
45 | |
---|
46 | template<typename X, typename Y> |
---|
47 | class _bz_update : public _bz_updater_base { |
---|
48 | public: |
---|
49 | static inline void update(X& restrict x, Y y) |
---|
50 | { x = (X)y; } |
---|
51 | |
---|
52 | static void prettyPrint(BZ_STD_SCOPE(string) &str) |
---|
53 | { str += "="; } |
---|
54 | }; |
---|
55 | |
---|
56 | BZ_DECL_UPDATER(_bz_plus_update, +=, "+="); |
---|
57 | BZ_DECL_UPDATER(_bz_minus_update, -=, "-="); |
---|
58 | BZ_DECL_UPDATER(_bz_multiply_update, *=, "*="); |
---|
59 | BZ_DECL_UPDATER(_bz_divide_update, /=, "/="); |
---|
60 | BZ_DECL_UPDATER(_bz_mod_update, %=, "%="); |
---|
61 | BZ_DECL_UPDATER(_bz_xor_update, ^=, "^="); |
---|
62 | BZ_DECL_UPDATER(_bz_bitand_update, &=, "&="); |
---|
63 | BZ_DECL_UPDATER(_bz_bitor_update, |=, "|="); |
---|
64 | BZ_DECL_UPDATER(_bz_shiftl_update, <<=, "<<="); |
---|
65 | BZ_DECL_UPDATER(_bz_shiftr_update, >>=, ">>="); |
---|
66 | |
---|
67 | BZ_NAMESPACE_END |
---|
68 | |
---|
69 | #endif // BZ_UPDATE_H |
---|
70 | |
---|