Browse Source

Some more changes towards C++-11. Not yet though

enhancement_3
Trevor Irons 8 years ago
parent
commit
237b8725a3

+ 3
- 4
Modules/FDEM1D/include/DipoleSource.h View File

14
 #ifndef __DIPOLESOURCE_H
14
 #ifndef __DIPOLESOURCE_H
15
 #define __DIPOLESOURCE_H
15
 #define __DIPOLESOURCE_H
16
 
16
 
17
+#include "LemmaObject.h"
17
 #include "LayeredEarthEM.h"
18
 #include "LayeredEarthEM.h"
18
-#include "FieldPoints.h"
19
-
20
-//#include "emearth1d.h"
21
 
19
 
22
 #ifdef LEMMAUSEVTK
20
 #ifdef LEMMAUSEVTK
23
 #include "vtkActor.h"
21
 #include "vtkActor.h"
33
 
31
 
34
     // Forward declarations
32
     // Forward declarations
35
     class KernelEM1DManager;
33
     class KernelEM1DManager;
34
+    class FieldPoints;
36
     class HankelTransform;
35
     class HankelTransform;
37
 
36
 
38
     // ==========================================================================
37
     // ==========================================================================
41
     /// \details  More complex sources are constructed from a superposition of
40
     /// \details  More complex sources are constructed from a superposition of
42
     ///           dipoles.
41
     ///           dipoles.
43
     // ==========================================================================
42
     // ==========================================================================
44
-    class DipoleSource : public LemmaObject {
43
+    class DipoleSource : public std::enable_shared_from_this<DipoleSource>,  LemmaObject {
45
 
44
 
46
         // ====================    FRIENDS     ======================
45
         // ====================    FRIENDS     ======================
47
 
46
 

+ 2
- 1
Modules/FDEM1D/include/KernelEM1DManager.h View File

36
 
36
 
37
         struct ctor_key {};
37
         struct ctor_key {};
38
 
38
 
39
+        /** Recursively streams information about this class */
39
         friend std::ostream &operator<<(std::ostream &stream, const KernelEM1DManager &ob);
40
         friend std::ostream &operator<<(std::ostream &stream, const KernelEM1DManager &ob);
40
 
41
 
41
         public:
42
         public:
43
             // ====================  LIFECYCLE     =======================
44
             // ====================  LIFECYCLE     =======================
44
 
45
 
45
             /** Default protected constructor. */
46
             /** Default protected constructor. */
46
-            KernelEM1DManager (const std::string& name);
47
+            KernelEM1DManager ( const ctor_key& );
47
 
48
 
48
             /** Default protected constructor. */
49
             /** Default protected constructor. */
49
             ~KernelEM1DManager ();
50
             ~KernelEM1DManager ();

+ 6
- 7
Modules/FDEM1D/include/KernelEM1DReflSpec.h View File

15
 #define  KERNELEM1DREFLSPEC_INC
15
 #define  KERNELEM1DREFLSPEC_INC
16
 
16
 
17
 #include "DipoleSource.h"
17
 #include "DipoleSource.h"
18
-#include "LayeredEarthEM.h"
19
-
20
 #include "kernelem1dreflbase.h"
18
 #include "kernelem1dreflbase.h"
19
+#include "LayeredEarthEM.h"
21
 
20
 
22
 namespace Lemma {
21
 namespace Lemma {
23
 
22
 
24
     // forward declaration for friend
23
     // forward declaration for friend
25
-    template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
26
-    class KernelEM1DSpec;
24
+    //template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
25
+    //class KernelEM1DSpec;
27
 
26
 
28
     // ===================================================================
27
     // ===================================================================
29
     //  Class:  KernelEM1DReflSpec
28
     //  Class:  KernelEM1DReflSpec
45
 
44
 
46
         public:
45
         public:
47
 
46
 
48
-            // what do these template parameters do -TI
49
-            template<EMMODE Mode2, int Ikernel2, DIPOLE_LOCATION Isource2, DIPOLE_LOCATION Irecv2>
50
-            friend class KernelEM1DSpec;
47
+            //template<EMMODE Mode2, int Ikernel2, DIPOLE_LOCATION Isource2, DIPOLE_LOCATION Irecv2>
48
+            //friend class KernelEM1DSpec;
49
+
51
             friend class KernelEM1DManager;
50
             friend class KernelEM1DManager;
52
 
51
 
53
             // ====================  LIFECYCLE     =======================
52
             // ====================  LIFECYCLE     =======================

+ 4
- 4
Modules/FDEM1D/include/kernelem1dreflbase.h View File

24
     enum DIPOLE_LOCATION { INAIR, INGROUND };
24
     enum DIPOLE_LOCATION { INAIR, INGROUND };
25
 
25
 
26
     // forward declaration for friend
26
     // forward declaration for friend
27
-    //template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
28
-    //class KernelEM1DSpec;
27
+    template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
28
+    class KernelEM1DSpec;
29
 
29
 
30
 
30
 
31
     // ===================================================================
31
     // ===================================================================
38
     // ===================================================================
38
     // ===================================================================
39
     class KernelEM1DReflBase : public LemmaObject {
39
     class KernelEM1DReflBase : public LemmaObject {
40
 
40
 
41
-        //template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
41
+        template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
42
         friend class KernelEM1DSpec;
42
         friend class KernelEM1DSpec;
43
-        //friend class KernelEM1DManager;
43
+        friend class KernelEM1DManager;
44
         //friend class DipoleSource;
44
         //friend class DipoleSource;
45
 
45
 
46
         public:
46
         public:

+ 6
- 1
Modules/FDEM1D/src/CMakeLists.txt View File

4
 	${CMAKE_CURRENT_SOURCE_DIR}/LayeredEarthEM.cpp
4
 	${CMAKE_CURRENT_SOURCE_DIR}/LayeredEarthEM.cpp
5
 	${CMAKE_CURRENT_SOURCE_DIR}/FieldPoints.cpp
5
 	${CMAKE_CURRENT_SOURCE_DIR}/FieldPoints.cpp
6
 	${CMAKE_CURRENT_SOURCE_DIR}/WireAntenna.cpp
6
 	${CMAKE_CURRENT_SOURCE_DIR}/WireAntenna.cpp
7
-#	${CMAKE_CURRENT_SOURCE_DIR}/DipoleSource.cpp
7
+	${CMAKE_CURRENT_SOURCE_DIR}/KernelEM1DManager.cpp
8
+	${CMAKE_CURRENT_SOURCE_DIR}/DipoleSource.cpp
9
+	
10
+	${CMAKE_CURRENT_SOURCE_DIR}/KernelEM1DReflSpec.cpp
11
+	${CMAKE_CURRENT_SOURCE_DIR}/KernelEM1DSpec.cpp
12
+
8
 	#${CMAKE_CURRENT_SOURCE_DIR}/UngroundedElectricDipole.cpp
13
 	#${CMAKE_CURRENT_SOURCE_DIR}/UngroundedElectricDipole.cpp
9
 	PARENT_SCOPE
14
 	PARENT_SCOPE
10
 )
15
 )

+ 1
- 1
Modules/FDEM1D/src/DipoleSource.cpp View File

13
 
13
 
14
 #include "DipoleSource.h"
14
 #include "DipoleSource.h"
15
 #include "KernelEM1DManager.h"
15
 #include "KernelEM1DManager.h"
16
-#include "FieldPoints.h"
17
 
16
 
18
 //#include "GroundedElectricDipole.h"
17
 //#include "GroundedElectricDipole.h"
19
 //#include "UngroundedElectricDipole.h"
18
 //#include "UngroundedElectricDipole.h"
20
 //#include "MagneticDipole.h"
19
 //#include "MagneticDipole.h"
21
 
20
 
21
+#include "FieldPoints.h"
22
 #include "hankeltransform.h"
22
 #include "hankeltransform.h"
23
 
23
 
24
 namespace Lemma {
24
 namespace Lemma {

+ 15
- 52
Modules/FDEM1D/src/KernelEM1DManager.cpp View File

11
   @version  $Id: kernelem1dmanager.cpp 193 2014-11-10 23:51:41Z tirons $
11
   @version  $Id: kernelem1dmanager.cpp 193 2014-11-10 23:51:41Z tirons $
12
  **/
12
  **/
13
 
13
 
14
-#include "kernelem1dmanager.h"
15
-
14
+#include "KernelEM1DManager.h"
16
 
15
 
17
 namespace Lemma {
16
 namespace Lemma {
18
 
17
 
19
-    std::ostream &operator<<(std::ostream &stream,
20
-                const KernelEM1DManager &ob) {
21
-        stream << *(LemmaObject*)(&ob);
18
+    std::ostream &operator<<(std::ostream &stream, const KernelEM1DManager &ob) {
19
+        stream << ob.Serialize() << "\n---\n";
22
         return stream;
20
         return stream;
23
     }
21
     }
24
 
22
 
25
 
23
 
26
     // ====================  LIFECYCLE     =======================
24
     // ====================  LIFECYCLE     =======================
27
 
25
 
28
-    KernelEM1DManager::KernelEM1DManager(const std::string& name) :
29
-                    LemmaObject(name), TEReflBase(NULL), TMReflBase(NULL), Earth(NULL), Dipole(NULL) {
26
+    KernelEM1DManager::KernelEM1DManager( const ctor_key& ) : LemmaObject( ), TEReflBase(nullptr),
27
+        TMReflBase(nullptr), Earth(nullptr), Dipole(nullptr) {
30
     }
28
     }
31
 
29
 
32
     KernelEM1DManager::~KernelEM1DManager() {
30
     KernelEM1DManager::~KernelEM1DManager() {
33
 
31
 
34
-        if (this->NumberOfReferences != 0)
35
-            throw DeleteObjectWithReferences(this);
36
-
37
-//         if (Earth != NULL) {
38
-//             Earth->DetachFrom(this);
39
-//         }
40
-//
41
-//         if (Dipole != NULL) {
42
-//             Dipole->DetachFrom(this);
43
-//         }
44
-
45
-        for (unsigned int ik=0; ik<KernelVec.size(); ++ik) {
46
-            KernelVec[ik]->Delete();
47
-        }
48
-
49
-        if (TEReflBase != NULL) TEReflBase->Delete();
50
-        if (TMReflBase != NULL) TMReflBase->Delete();
51
-
52
-    }
53
-
54
-    KernelEM1DManager* KernelEM1DManager::New() {
55
-        KernelEM1DManager* Obj = new KernelEM1DManager("KernelEM1DManager");
56
-        Obj->AttachTo(Obj);
57
-        return Obj;
58
     }
32
     }
59
 
33
 
60
-    void KernelEM1DManager::Delete() {
61
-        this->DetachFrom(this);
34
+    std::shared_ptr<KernelEM1DManager> KernelEM1DManager::NewSP() {
35
+        return std::make_shared<KernelEM1DManager>( ctor_key() );
62
     }
36
     }
63
 
37
 
64
-    void KernelEM1DManager::Release() {
65
-        delete this;
66
-    }
67
 
38
 
68
     // ====================  ACCESS        =======================
39
     // ====================  ACCESS        =======================
69
 
40
 
70
     // A race condition can develop with these. It's OK to not attach, since this is an internal class, and
41
     // A race condition can develop with these. It's OK to not attach, since this is an internal class, and
71
     // we know what is going on.
42
     // we know what is going on.
72
-    void KernelEM1DManager::SetEarth(LayeredEarthEM* Earthin) {
73
-        //if (Earth != NULL) {
74
-        //    Earth->DetachFrom(this);
75
-        //}
76
-        //Earthin->AttachTo(this);
43
+    void KernelEM1DManager::SetEarth( std::shared_ptr<LayeredEarthEM> Earthin) {
77
         Earth = Earthin;
44
         Earth = Earthin;
78
     }
45
     }
79
 
46
 
80
-    void KernelEM1DManager::SetDipoleSource(DipoleSource* DipoleIn, const int& ifreqin,
47
+    void KernelEM1DManager::SetDipoleSource( std::shared_ptr<DipoleSource> DipoleIn, const int& ifreqin,
81
             const Real& rx_zin) {
48
             const Real& rx_zin) {
82
-        //if (Dipole != NULL) {
83
-        //    Dipole->DetachFrom(this);
84
-        //}
85
-        //DipoleIn->AttachTo(this);
86
         Dipole = DipoleIn;
49
         Dipole = DipoleIn;
87
 
50
 
88
         ifreq = ifreqin;
51
         ifreq = ifreqin;
89
         rx_z = rx_zin;
52
         rx_z = rx_zin;
90
     }
53
     }
91
 
54
 
92
-    KernelEm1DBase* KernelEM1DManager::GetKernel(const unsigned int& ik) {
55
+    std::shared_ptr<KernelEm1DBase> KernelEM1DManager::GetKernel(const unsigned int& ik) {
93
         return KernelVec[ik];
56
         return KernelVec[ik];
94
     }
57
     }
95
 
58
 
96
-    DipoleSource* KernelEM1DManager::GetDipole( ) {
59
+    std::shared_ptr<DipoleSource> KernelEM1DManager::GetDipole( ) {
97
         return Dipole;
60
         return Dipole;
98
     }
61
     }
99
 
62
 
101
 
64
 
102
     void KernelEM1DManager::ComputeReflectionCoeffs(const Real& lambda, const int& idx, const Real& rho0) {
65
     void KernelEM1DManager::ComputeReflectionCoeffs(const Real& lambda, const int& idx, const Real& rho0) {
103
 
66
 
104
-        if (TEReflBase != NULL) {
67
+        if (TEReflBase != nullptr) {
105
             TEReflBase->ComputeReflectionCoeffs(lambda);
68
             TEReflBase->ComputeReflectionCoeffs(lambda);
106
             TEReflBase->PreComputePotentialTerms( );
69
             TEReflBase->PreComputePotentialTerms( );
107
         }
70
         }
108
 
71
 
109
-        if (TMReflBase != NULL) {
72
+        if (TMReflBase != nullptr) {
110
             TMReflBase->ComputeReflectionCoeffs(lambda);
73
             TMReflBase->ComputeReflectionCoeffs(lambda);
111
             TMReflBase->PreComputePotentialTerms( );
74
             TMReflBase->PreComputePotentialTerms( );
112
         }
75
         }
115
 
78
 
116
     void KernelEM1DManager::ResetSource(const int& ifreq) {
79
     void KernelEM1DManager::ResetSource(const int& ifreq) {
117
 
80
 
118
-        if (TEReflBase != NULL) {
81
+        if (TEReflBase != nullptr) {
119
             TEReflBase->SetUpSource(Dipole, ifreq);
82
             TEReflBase->SetUpSource(Dipole, ifreq);
120
         }
83
         }
121
 
84
 
122
-        if (TMReflBase != NULL) {
85
+        if (TMReflBase != nullptr) {
123
             TMReflBase->SetUpSource(Dipole, ifreq);
86
             TMReflBase->SetUpSource(Dipole, ifreq);
124
 
87
 
125
         }
88
         }

Modules/FDEM1D/src/kernelem1dreflspec.cpp → Modules/FDEM1D/src/KernelEM1DReflSpec.cpp View File

11
   @version  $Id: kernelem1dreflspec.cpp 169 2014-09-06 22:16:12Z tirons $
11
   @version  $Id: kernelem1dreflspec.cpp 169 2014-09-06 22:16:12Z tirons $
12
  **/
12
  **/
13
 
13
 
14
-#include "kernelem1dreflspec.h"
14
+#include "KernelEM1DReflSpec.h"
15
 
15
 
16
 namespace Lemma {
16
 namespace Lemma {
17
 
17
 

Modules/FDEM1D/src/kernelem1dspec.cpp → Modules/FDEM1D/src/KernelEM1DSpec.cpp View File

11
   @version  $Id: kernelem1dspec.cpp 87 2013-09-05 22:44:05Z tirons $
11
   @version  $Id: kernelem1dspec.cpp 87 2013-09-05 22:44:05Z tirons $
12
  **/
12
  **/
13
 
13
 
14
-#include "kernelem1dspec.h"
14
+#include "KernelEM1DSpec.h"
15
 
15
 
16
 namespace Lemma {
16
 namespace Lemma {
17
 
17
 

+ 1
- 1
Modules/LemmaCore/include/LemmaObject.h View File

34
   *           standard. All Lemma objects should be created as C++-11 Smart pointers, using
34
   *           standard. All Lemma objects should be created as C++-11 Smart pointers, using
35
   *           the supplied New method. Calls to Delete are no longer necessary or available.
35
   *           the supplied New method. Calls to Delete are no longer necessary or available.
36
   */
36
   */
37
-class LemmaObject : public std::enable_shared_from_this<LemmaObject> {
37
+class LemmaObject {
38
 
38
 
39
     /**
39
     /**
40
      *  Streams class information as YAML::Node
40
      *  Streams class information as YAML::Node

Loading…
Cancel
Save