My favorites | Sign in
Project Home Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/********************************************\
*
* Sire - Molecular Simulation Framework
*
* Copyright (C) 2009 Christopher Woods
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* For full details of the license please see the COPYING file
* that should have come with this distribution.
*
* You can contact the authors via the developer's mailing list
* at http://siremol.org
*
\*********************************************/

#ifndef SIREN_HANREF_H
#define SIREN_HANREF_H

#include "handle.h"

SIREN_BEGIN_HEADER

namespace Siren
{

/** This is a small and simple class that provides a reference
to a handle. This is an explicitly shared reference to
an explicitly shared handle
*/
class SIREN_EXPORT HanRef
{
public:
HanRef();
HanRef(Handle *handle);
HanRef(const Handle &handle);

HanRef(const HanRef &other);

~HanRef();

HanRef& operator=(const HanRef &other);

bool operator==(const HanRef &other) const;
bool operator!=(const HanRef &other) const;

const Class& getClass() const;

QString what() const;

HanRef clone() const;

bool test() const;
bool test(Logger &logger) const;

void copy(const Handle &other);

bool equals(const Handle &other) const;

uint hashCode() const;

void lock();
void unlock();

bool tryLock();
bool tryLock(int ms);

bool isNull() const;

template<class T>
bool isA() const;

template<class T>
T& asA();

template<class T>
const T& asA() const;

operator const Handle&() const;

private:
void detach();

static void throwNullPtrError(const QString &type_name);

/** Explicitly shared pointer to the handle */
boost::shared_ptr<Handle> d;
};

#ifndef SIREN_SKIP_INLINE_FUNCTIONS

/** Return whether or not this HandleRef refers to a Handle of type 'T' */
template<class T>
SIREN_OUTOFLINE_TEMPLATE
bool HanRef::isA() const
{
if (d.get() != 0)
return d->isA<T>();
else
return false;
}

/** Return this HandleRef cast as type 'T'

\throw Siren::invalid_cast
*/
template<class T>
SIREN_OUTOFLINE_TEMPLATE
T& HanRef::asA()
{
if (d.get() == 0)
this->throwNullPtrError( T::typeName() );

return d->asA<T>();
}

/** Return this HandleRef cast as type 'T'

\throw Siren::invalid_cast
*/
template<class T>
SIREN_OUTOFLINE_TEMPLATE
const T& HanRef::asA() const
{
if (d.get() == 0)
this->throwNullPtrError( T::typeName() );

return d->asA<T>();
}

#endif // SIREN_SKIP_INLINE_FUNCTIONS

}

SIREN_EXPOSE_CLASS( Siren::HanRef )

SIREN_END_HEADER

#endif

Change log

r1121 by chryswoods on Dec 2, 2009   Diff
Sire (and Siren) now compile and work on
HPCx, with parallel jobs working without
problem.
The only difficulty now is that there are
QBuffer memory errors which are causing
problems
writing and reading restart files. When I
had these before they were caused by a
non-thread-safe malloc which was brought
in by the MPI libraries...

I've also merged into
...
Go to: 
Sign in to write a code review

Older revisions

r1102 by chryswoods on Nov 20, 2009   Diff
I've got Siren compiled and linked,
and have got (most) of the python
wrappers working.
The code works, to an extent, but
there are quite a few problems and
...
r1101 by chryswoods on Nov 20, 2009   Diff
I've filled in most of the missing
functions in Siren - I just need to
finish off DataStream and Tester.
Once they are complete, I should be
able to link and then test Siren
...
r1093 by chryswoods on Nov 15, 2009   Diff
I've created the Handle hierarchy of
classes which are used to provide the
equivalent
of Object for shared data types.
Handle provides handles with which to
...
All revisions of this file

File info

Size: 3390 bytes, 151 lines
Powered by Google Project Hosting