Itasca C++ Interface
Toggle main menu visibility
Loading...
Searching...
No Matches
sharedpropertyblock.h
Go to the documentation of this file.
1
#pragma once
2
//
3
12
13
14
#include "
propertyblock.h
"
15
#include "shared/src/blockmemset.h"
16
17
namespace
models
{
22
23
template
<
class
T>
class
SharedPropertyBlock
{
24
public
:
26
SharedPropertyBlock
() { }
28
virtual
~SharedPropertyBlock
() { }
29
31
const
T *
claim
(
const
T &t);
33
void
release
(
const
T *t);
34
35
private
:
36
BlockMemSet<T> properties_;
37
};
38
39
template
<
class
T>
const
T *
SharedPropertyBlock<T>::claim
(
const
T &in) {
40
auto
i = properties_.insert(in);
41
const
T &t = *i.first;
42
t.incrementReference();
43
return
&t;
44
}
45
46
template
<
class
T>
void
SharedPropertyBlock<T>::release
(
const
T *t) {
47
assert(t);
48
auto
i = properties_.find(*t);
49
assert(i!=properties_.end());
50
const
T &found = *i;
51
assert(&found==t);
52
if
(!found.decrementReference())
53
properties_.erase(i);
54
}
55
}
// namespace models
56
58
// EoF
models::SharedPropertyBlock::claim
const T * claim(const T &t)
Add property t to the property set and increase the property reference count (See SharedProperty).
Definition
sharedpropertyblock.h:39
models::SharedPropertyBlock::SharedPropertyBlock
SharedPropertyBlock()
Constructor.
Definition
sharedpropertyblock.h:26
models::SharedPropertyBlock::release
void release(const T *t)
Decreases property t reference count. If the properrty reference reaches zero, removes property from ...
Definition
sharedpropertyblock.h:46
models::SharedPropertyBlock::~SharedPropertyBlock
virtual ~SharedPropertyBlock()
Destructor.
Definition
sharedpropertyblock.h:28
models
The Constitutive Model interface library.
Definition
conmodel.cpp:7
propertyblock.h
This class provides reference count for model properties.
common
models
src
sharedpropertyblock.h
Generated by
1.18.0