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

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

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

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

@@ -15,15 +15,14 @@
15 15
 #define  KERNELEM1DREFLSPEC_INC
16 16
 
17 17
 #include "DipoleSource.h"
18
-#include "LayeredEarthEM.h"
19
-
20 18
 #include "kernelem1dreflbase.h"
19
+#include "LayeredEarthEM.h"
21 20
 
22 21
 namespace Lemma {
23 22
 
24 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 28
     //  Class:  KernelEM1DReflSpec
@@ -45,9 +44,9 @@ namespace Lemma {
45 44
 
46 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 50
             friend class KernelEM1DManager;
52 51
 
53 52
             // ====================  LIFECYCLE     =======================

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

@@ -24,8 +24,8 @@ namespace Lemma {
24 24
     enum DIPOLE_LOCATION { INAIR, INGROUND };
25 25
 
26 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,9 +38,9 @@ namespace Lemma {
38 38
     // ===================================================================
39 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 42
         friend class KernelEM1DSpec;
43
-        //friend class KernelEM1DManager;
43
+        friend class KernelEM1DManager;
44 44
         //friend class DipoleSource;
45 45
 
46 46
         public:

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

@@ -4,7 +4,12 @@ set (FEM1DSOURCE
4 4
 	${CMAKE_CURRENT_SOURCE_DIR}/LayeredEarthEM.cpp
5 5
 	${CMAKE_CURRENT_SOURCE_DIR}/FieldPoints.cpp
6 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 13
 	#${CMAKE_CURRENT_SOURCE_DIR}/UngroundedElectricDipole.cpp
9 14
 	PARENT_SCOPE
10 15
 )

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

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

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

@@ -11,89 +11,52 @@
11 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 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 20
         return stream;
23 21
     }
24 22
 
25 23
 
26 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 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 39
     // ====================  ACCESS        =======================
69 40
 
70 41
     // A race condition can develop with these. It's OK to not attach, since this is an internal class, and
71 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 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 48
             const Real& rx_zin) {
82
-        //if (Dipole != NULL) {
83
-        //    Dipole->DetachFrom(this);
84
-        //}
85
-        //DipoleIn->AttachTo(this);
86 49
         Dipole = DipoleIn;
87 50
 
88 51
         ifreq = ifreqin;
89 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 56
         return KernelVec[ik];
94 57
     }
95 58
 
96
-    DipoleSource* KernelEM1DManager::GetDipole( ) {
59
+    std::shared_ptr<DipoleSource> KernelEM1DManager::GetDipole( ) {
97 60
         return Dipole;
98 61
     }
99 62
 
@@ -101,12 +64,12 @@ namespace Lemma {
101 64
 
102 65
     void KernelEM1DManager::ComputeReflectionCoeffs(const Real& lambda, const int& idx, const Real& rho0) {
103 66
 
104
-        if (TEReflBase != NULL) {
67
+        if (TEReflBase != nullptr) {
105 68
             TEReflBase->ComputeReflectionCoeffs(lambda);
106 69
             TEReflBase->PreComputePotentialTerms( );
107 70
         }
108 71
 
109
-        if (TMReflBase != NULL) {
72
+        if (TMReflBase != nullptr) {
110 73
             TMReflBase->ComputeReflectionCoeffs(lambda);
111 74
             TMReflBase->PreComputePotentialTerms( );
112 75
         }
@@ -115,11 +78,11 @@ namespace Lemma {
115 78
 
116 79
     void KernelEM1DManager::ResetSource(const int& ifreq) {
117 80
 
118
-        if (TEReflBase != NULL) {
81
+        if (TEReflBase != nullptr) {
119 82
             TEReflBase->SetUpSource(Dipole, ifreq);
120 83
         }
121 84
 
122
-        if (TMReflBase != NULL) {
85
+        if (TMReflBase != nullptr) {
123 86
             TMReflBase->SetUpSource(Dipole, ifreq);
124 87
 
125 88
         }

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

@@ -11,7 +11,7 @@
11 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 16
 namespace Lemma {
17 17
 

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

@@ -11,7 +11,7 @@
11 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 16
 namespace Lemma {
17 17
 

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

@@ -34,7 +34,7 @@ namespace Lemma {
34 34
   *           standard. All Lemma objects should be created as C++-11 Smart pointers, using
35 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 40
      *  Streams class information as YAML::Node

Loading…
Cancel
Save