NetOceanDirect  2.4.0
OceanDirect .NET API
ManagedObject.h
1 #pragma once
2 using namespace System;
3 
4 namespace NetOceanDirect {
5 
6  template<class T>
7  public ref class ManagedObject
8  {
9  protected:
10  T* m_Instance;
11  public:
12  ManagedObject(T* instance)
13  : m_Instance(instance)
14  {
15  }
16  virtual ~ManagedObject()
17  {
18  // This is where managed resources should be cleaned up followed
19  // by the finalizer to clean up unmanaged resources
20  this->!ManagedObject();
21  }
22  !ManagedObject()
23  {
24  // Clean up unmanaged resources.
25  // This template is normally used to access native code through the
26  // pointer...
27  if (m_Instance != nullptr)
28  {
29  delete m_Instance;
30  }
31  }
32  T* GetInstance()
33  {
34  return m_Instance;
35  }
36  };
37 }
Definition: ManagedObject.h:8