libyui
 
Loading...
Searching...
No Matches
YBothDim.h
1/*
2 Copyright (C) 2000-2012 Novell, Inc
3 This library is free software; you can redistribute it and/or modify
4 it under the terms of the GNU Lesser General Public License as
5 published by the Free Software Foundation; either version 2.1 of the
6 License, or (at your option) version 3.0 of the License. This library
7 is distributed in the hope that it will be useful, but WITHOUT ANY
8 WARRANTY; without even the implied warranty of MERCHANTABILITY or
9 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10 License for more details. You should have received a copy of the GNU
11 Lesser General Public License along with this library; if not, write
12 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13 Floor, Boston, MA 02110-1301 USA
14*/
15
16
17/*-/
18
19 File: YBothDim.h
20
21 Author: Stefan Hundhammer <shundhammer@suse.de>
22
23/-*/
24
25#ifndef YBothDim_h
26#define YBothDim_h
27
28#include "YTypes.h"
29#include "YUIException.h"
30
31
41template<typename T> class YBothDim
42{
43public:
44
45 // Data Members - intentionally public
46 T vert;
47 T hor;
48
52 YBothDim( T hor, T vert )
53 : vert( vert )
54 , hor( hor )
55 {}
56
61 {}
62
68 T & operator[]( YUIDimension dim )
69 {
70 switch ( dim )
71 {
72 case YD_HORIZ: return hor;
73 case YD_VERT: return vert;
74 default: YUI_THROW( YUIInvalidDimensionException() );
75 }
76
77 // never reached (but gcc will complain otherwise)
78 return hor;
79 }
80
84 const T & operator[]( YUIDimension dim ) const
85 {
86 switch ( dim )
87 {
88 case YD_HORIZ: return hor;
89 case YD_VERT: return vert;
90 default: YUI_THROW( YUIInvalidDimensionException() );
91 }
92
93 // never reached (but gcc will complain otherwise)
94 return hor;
95 }
96};
97
98
99#endif // YBothDim_h
YBothDim()
Definition YBothDim.h:60
const T & operator[](YUIDimension dim) const
Definition YBothDim.h:84
T & operator[](YUIDimension dim)
Definition YBothDim.h:68
YBothDim(T hor, T vert)
Definition YBothDim.h:52
Definition YUIException.h:793