Action_Thermostats
Add_AtomRandomPerturbation
Add_RotateAroundBondAction
Add_SelectAtomByNameAction
Adding_Graph_to_ChangeBondActions
Adding_MD_integration_tests
Adding_StructOpt_integration_tests
Automaking_mpqc_open
AutomationFragmentation_failures
Candidate_v1.6.0
Candidate_v1.6.1
ChangeBugEmailaddress
ChangingTestPorts
ChemicalSpaceEvaluator
Combining_Subpackages
Debian_Package_split
Debian_package_split_molecuildergui_only
Disabling_MemDebug
Docu_Python_wait
EmpiricalPotential_contain_HomologyGraph_documentation
Enable_parallel_make_install
Enhance_userguide
Enhanced_StructuralOptimization
Enhanced_StructuralOptimization_continued
Example_ManyWaysToTranslateAtom
Exclude_Hydrogens_annealWithBondGraph
FitPartialCharges_GlobalError
Fix_ChronosMutex
Fix_StatusMsg
Fix_StepWorldTime_single_argument
Fix_Verbose_Codepatterns
ForceAnnealing_goodresults
ForceAnnealing_oldresults
ForceAnnealing_tocheck
ForceAnnealing_with_BondGraph
ForceAnnealing_with_BondGraph_continued
ForceAnnealing_with_BondGraph_continued_betteresults
ForceAnnealing_with_BondGraph_contraction-expansion
GeometryObjects
Gui_displays_atomic_force_velocity
IndependentFragmentGrids_IntegrationTest
JobMarket_RobustOnKillsSegFaults
JobMarket_StableWorkerPool
JobMarket_unresolvable_hostname_fix
ODR_violation_mpqc_open
PartialCharges_OrthogonalSummation
PythonUI_with_named_parameters
QtGui_reactivate_TimeChanged_changes
Recreated_GuiChecks
RotateToPrincipalAxisSystem_UndoRedo
StoppableMakroAction
Subpackage_CodePatterns
Subpackage_JobMarket
Subpackage_levmar
Subpackage_mpqc_open
Subpackage_vmg
ThirdParty_MPQC_rebuilt_buildsystem
TremoloParser_IncreasedPrecision
TremoloParser_MultipleTimesteps
Ubuntu_1604_changes
stable
Line | |
---|
1 | /*
|
---|
2 | * AtomicInstance_impl.hpp
|
---|
3 | *
|
---|
4 | * Created on: Apr 26, 2016
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 |
|
---|
9 | #ifndef ATOMICINSTANCE_IMPL_HPP_
|
---|
10 | #define ATOMICINSTANCE_IMPL_HPP_
|
---|
11 |
|
---|
12 | // include config.h
|
---|
13 | #ifdef HAVE_CONFIG_H
|
---|
14 | #include <config.h>
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #include "CodePatterns/Assert.hpp"
|
---|
18 |
|
---|
19 | #include "AtomicInstance.hpp"
|
---|
20 |
|
---|
21 | template<class T> boost::mutex AtomicInstance< T >::atomicLock;
|
---|
22 |
|
---|
23 | template <class T>
|
---|
24 | AtomicInstance<T>::AtomicInstance(T* _content) :
|
---|
25 | content(_content)
|
---|
26 | {
|
---|
27 | if (content != NULL)
|
---|
28 | AtomicInstance<T>::atomicLock.lock();
|
---|
29 | }
|
---|
30 |
|
---|
31 | template <class T>
|
---|
32 | AtomicInstance<T>::AtomicInstance() :
|
---|
33 | content(NULL)
|
---|
34 | {
|
---|
35 | }
|
---|
36 |
|
---|
37 | template <class T>
|
---|
38 | AtomicInstance<T>::~AtomicInstance()
|
---|
39 | {
|
---|
40 | if (content != NULL)
|
---|
41 | AtomicInstance<T>::atomicLock.unlock();
|
---|
42 | }
|
---|
43 |
|
---|
44 | template <class T>
|
---|
45 | T& AtomicInstance<T>::operator*()
|
---|
46 | { return *content;}
|
---|
47 |
|
---|
48 | template <class T>
|
---|
49 | const T& AtomicInstance<T>::operator*() const
|
---|
50 | { return *content;}
|
---|
51 |
|
---|
52 | template <class T>
|
---|
53 | AtomicInstance<T>& AtomicInstance<T>::operator=(const AtomicInstance<T>& rhs)
|
---|
54 | {
|
---|
55 | if (this != &rhs) {
|
---|
56 | this->content = rhs.content;
|
---|
57 | const_cast<AtomicInstance<T>&>(rhs).content = NULL;
|
---|
58 | }
|
---|
59 | return *this;
|
---|
60 | }
|
---|
61 |
|
---|
62 | template <class T>
|
---|
63 | AtomicInstance<T>::AtomicInstance(AtomicInstance<T>& rhs) :
|
---|
64 | content(rhs.content)
|
---|
65 | {
|
---|
66 | // check for self-copy
|
---|
67 | if (this != &rhs)
|
---|
68 | rhs.content = NULL;
|
---|
69 | }
|
---|
70 |
|
---|
71 | template <class T>
|
---|
72 | AtomicInstance<T>::AtomicInstance(const AtomicInstance<T>& rhs) :
|
---|
73 | content(rhs.content)
|
---|
74 | {
|
---|
75 | // check for self-copy
|
---|
76 | ASSERT (this != &rhs,
|
---|
77 | "AtomicInstance<T>::AtomicInstance() - self-assignment not allowed for rhs copy.");
|
---|
78 | const_cast<AtomicInstance<T>&>(rhs).content = NULL;
|
---|
79 | }
|
---|
80 |
|
---|
81 | #endif /* ATOMICINSTANCE_IMPL_HPP_ */
|
---|
Note:
See
TracBrowser
for help on using the repository browser.