Clipper
container_hkl.h
1
4//C Copyright (C) 2000-2006 Kevin Cowtan and University of York
5//L
6//L This library is free software and is distributed under the terms
7//L and conditions of version 2.1 of the GNU Lesser General Public
8//L Licence (LGPL) with the following additional clause:
9//L
10//L `You may also combine or link a "work that uses the Library" to
11//L produce a work containing portions of the Library, and distribute
12//L that work under terms of your choice, provided that you give
13//L prominent notice with each copy of the work that the specified
14//L version of the Library is used in it, and that you include or
15//L provide public access to the complete corresponding
16//L machine-readable source code for the Library including whatever
17//L changes were used in the work. (i.e. If you make changes to the
18//L Library you must distribute those, but you do not need to
19//L distribute source or object code to those portions of the work
20//L not covered by this licence.)'
21//L
22//L Note that this clause grants an additional right and does not impose
23//L any additional restriction, and so does not affect compatibility
24//L with the GNU General Public Licence (GPL). If you wish to negotiate
25//L other terms, please contact the maintainer.
26//L
27//L You can redistribute it and/or modify the library under the terms of
28//L the GNU Lesser General Public License as published by the Free Software
29//L Foundation; either version 2.1 of the License, or (at your option) any
30//L later version.
31//L
32//L This library is distributed in the hope that it will be useful, but
33//L WITHOUT ANY WARRANTY; without even the implied warranty of
34//L MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35//L Lesser General Public License for more details.
36//L
37//L You should have received a copy of the CCP4 licence and/or GNU
38//L Lesser General Public License along with this library; if not, write
39//L to the CCP4 Secretary, Daresbury Laboratory, Warrington WA4 4AD, UK.
40//L The GNU Lesser General Public can also be obtained by writing to the
41//L Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
42//L MA 02111-1307 USA
43
44
45#ifndef CLIPPER_CONTAINER_HKL
46#define CLIPPER_CONTAINER_HKL
47
48
49#include "container_types.h"
50#include "hkl_data.h"
51
52
53namespace clipper
54{
55
56 extern const HKL_info NullHKL_info; //<! null instance
57
58
60
63 class CHKL_info : public Container, public HKL_info
64 {
65 public:
67 CHKL_info( const String name = "",
68 const Spacegroup& spacegroup = NullSpacegroup,
69 const Cell& cell = NullCell,
70 const Resolution& resolution = NullResolution,
71 const bool& generate = false );
73 CHKL_info( Container& parent, const String name = "",
74 const bool& generate = false );
76 void init( const Spacegroup& spacegroup, const Cell& cell,
77 const Resolution& resolution, const bool& generate = false );
78
80 void generate_hkl_list();
82 void update();
83 private:
84 bool generate_;
85 };
86
87
89
91 template<class T> class CHKL_data : public Container, public HKL_data<T>
92 {
93 public:
97 CHKL_data( Container& parent, const String name = "" );
99 void init( const HKL_info& hkl_info, const Cell& cell );
101 void init( const Spacegroup& spacegroup, const Cell& cell, const HKL_sampling& hkl_sampling ) { clipper::Message::message( clipper::Message_fatal("CHKL_data deprecated") ); }
103 void update();
104
107 { return ( dynamic_cast<HKL_data<T>&>(*this) = other ); }
109 HKL_data<T>& operator =( const T& value )
110 { return ( dynamic_cast<HKL_data<T>&>(*this) = value ); }
111 };
112
113
114 // template implementations
115
116
124 template<class T> CHKL_data<T>::CHKL_data( Container& parent, const String name ) : Container( parent, name )
125 {
126 init( NullHKL_info, NullCell );
127 }
128
129
135 template<class T> void CHKL_data<T>::init( const HKL_info& hkl_info, const Cell& cell )
136 {
137 // use supplied values by default
138 const HKL_info* hp = &hkl_info;
139 const Cell* cp = &cell;
140 // otherwise get them from the tree
141 if ( hp->is_null() ) hp = parent_of_type_ptr<const HKL_info>();
142 if ( cp->is_null() ) cp = parent_of_type_ptr<const Cell>();
143 // if we have an hkl_info, try and init
144 if ( hp != NULL ) {
145 // if no cell then inherit
146 if ( cp == NULL ) cp = &(hp->cell());
147 // now initialise
148 if ( !hp->is_null() && !cp->is_null() )
149 HKL_data<T>::init( *hp, *cp );
150 }
152 }
153
154
160 template<class T> void CHKL_data<T>::update()
161 {
163 init( NullHKL_info, NullCell );
164 else
167 }
168
169
170} // namespace clipper
171
172#endif
Reflection data list container.
Definition container_hkl.h:92
void update()
hierarchical update
Definition container_hkl.h:160
HKL_data< T > & operator=(const HKL_data< T > &other)
assignment operator: copies the data from another list
Definition container_hkl.h:106
CHKL_data()
null constructor
Definition container_hkl.h:95
void init(const HKL_info &hkl_info, const Cell &cell)
initialiser: supply or inherit hkl list, and cell
Definition container_hkl.h:135
void init(const Spacegroup &spacegroup, const Cell &cell, const HKL_sampling &hkl_sampling)
initialiser: from spacegroup, cell, and HKL_sampling
Definition container_hkl.h:101
HKL list and indexing object container.
Definition container_hkl.h:64
void init(const Spacegroup &spacegroup, const Cell &cell, const Resolution &resolution, const bool &generate=false)
initialiser: supply or inherit spacegroup, cell and resolution
Definition container_hkl.cpp:79
void generate_hkl_list()
synthesize hkl list and update children
Definition container_hkl.cpp:102
CHKL_info(const String name="", const Spacegroup &spacegroup=NullSpacegroup, const Cell &cell=NullCell, const Resolution &resolution=NullResolution, const bool &generate=false)
constructor: make null object or top object in tree
Definition container_hkl.cpp:56
void update()
hierarchical update
Definition container_hkl.cpp:112
Cell object.
Definition cell.h:122
bool is_null() const
test if object has been initialised
Definition cell.cpp:151
Definition for a generic container Object.
Definition container.h:69
const Container & parent() const
get the parent of this object
Definition container.cpp:142
String name() const
get the name of this tree object
Definition container.cpp:127
virtual void update()
update: hierarchical content update function
Definition container.cpp:65
const HKL_info & hkl_info() const
[CLIPPER2] get HKL_info object
Definition hkl_data.h:170
bool is_null() const
test if object has been initialised
Definition hkl_data.cpp:126
const HKL_sampling & hkl_sampling() const
[CLIPPER2] get HKL_sampling
Definition hkl_data.h:168
const Spacegroup & spacegroup() const
[CLIPPER2] get spacegroup
Definition hkl_data.h:162
const Cell & cell() const
[CLIPPER2] get cell
Definition hkl_data.h:164
HKL_data<>
Definition hkl_data.h:235
void update()
update: synchornize info with parent HKL_info
Definition hkl_data.h:409
void init(const HKL_info &hkl_info, const Cell &cell)
initialiser: from parent hkl_info and cell
Definition hkl_data.h:382
HKL list container and tree root.
Definition hkl_info.h:63
const Spacegroup & spacegroup() const
get the spacegroup
Definition hkl_info.h:80
bool is_null() const
test if object has been initialised
Definition hkl_info.cpp:190
const Resolution & resolution() const
get the resolution
Definition hkl_info.h:84
const Cell & cell() const
get the cell
Definition hkl_info.h:78
HKL sampling of reciprocal space.
Definition coords.h:553
Fatal message (level = 9)
Definition clipper_message.h:129
static void message(const T &message)
pass a message
Definition clipper_message.h:93
Resolution in angstroms.
Definition coords.h:69
Spacegroup object.
Definition spacegroup.h:173
String extension with simple parsing methods.
Definition clipper_types.h:65