Members of CComGITPtr
The various members of CComGITPtr class are as follows:
-
Constructors.
-
Destructors.
-
Data Members.
-
Methods.
-
Operators.
Public Constructor and Destructor
-
CComGITPtr::CComGITPtr is the public constructor that is used to initialize the new object of the class with the option of using an already existing one.
The move constructor is the one using rv. After the data has been transferred from the source(rv) it is cleared.
-
CComGITPtr::~CComGITPtr is the public destructor that is used to destroy the object.
CComGITPtr::CComGITPtr
The syntax of the public constructor is as follows:
CComGITPtr() throw();
CComGITPtr(T* p);
CComGITPtr(const CComGITPtr& git);
explicit CComGITPtr(DWORD dwCookie) throw();
CComGITPtr(CComGITPtr&& rv);
Parameters
-
p: A pointer to an interface that will be kept in the global interface table (GIT).
-
Git is a reference to a CComGITPtr object that already exists.
-
dwCookie: An interface pointer identification cookie.
- rv: The CComGITPtr object from which to move data.
CComGITPtr::~CComGITPtr
Using CComGITPtr::Revoke, the interface is removed from the GIT.
The syntax of the public destructor is as follows:
~CComGITPtr() throw();
Public Data Members
CComGITPtr::m_dwCookie is a cookie used as a data member of the CComGITPtr class. It is used to identify the location of the interface and the interface itself.
The syntax of the data member is as follows:
DWORD m_dwCookie;
Public Methods
-
CComGITPtr::Attach method is used to add the interface pointer to the GIT.
-
CComGITPtr::CopyTo method is used to copy the interface pointer from GIT into a specified pointer.
-
CComGITPtr::Detach method is used to separate the interface from the CComGITPtr object.
-
CComGITPtr::GetCookie method is used to retrieve the cookie from the CComGITPtr object.
- CComGITPtr::Revoke method deletes the interface from the global interface table.
CComGITPtr::Attach
The syntax for this method is as follows:
HRESULT Attach(T* p) throw();
HRESULT Attach(DWORD dwCookie) throw();
Parameters
-
p: A pointer to an interface that will be kept in the global interface table (GIT).
- dwCookie: An interface pointer identification cookie.
Return Value
Success: S_OK
Failure: HRESULT (error)
CComGITPtr::CopyTo
The passed pointer receives a copy of the GIT interface. When it is no longer needed, the caller must release the pointer.
The syntax of this method is as follows:
HRESULT CopyTo(T** pp) const throw();
Parameters
pp: The pointer that will be given access to the interface.
Return Value
Success: S_OK
Failure: HRESULT (error)
CComGITPtr::Detach
To separate the interface from the CComGITPtr object, call this method.
The syntax of this method is as follows:
DWORD Detach() throw();
Return Value
The cookie is returned from the CComGITPtr object in the return value.
CComGITPtr::GetCookie
To retrieve the cookie from the CComGITPtr object, call this method.
The syntax of this method is as follows:
DWORD GetCookie() const;
Return Value
The cookie to identify an interface.
CComGITPtr::Revoke
Use this method to delete the current interface from the global interface table.
The syntax of this method is as follows:
HRESULT Revoke() throw();
Return Value
Success: S_OK
Failure: HRESULT (error)
Public Operators
-
CComGITPtr::operator DWORD operator gives the CComGITPtr object's related cookie back.
-
CComGITPtr::operator = is the assignment operator.
CComGITPtr::operator DWORD
The received cookie is used to identify an interface pointer.
The prototype for this operator is as follows:
operator DWORD() const;
CComGITPtr::operator =
It assigns a CComGITPtr object. You can derive a new value from another existing object or a reference to a global interface table.
The prototype for this operator is as follows:
CComGITPtr& operator= (T* p);
CComGITPtr& operator= (const CComGITPtr& git);
CComGITPtr& operator= (DWORD dwCookie);
CComGITPtr& operator= (CComGITPtr&& rv);
Parameters
-
p: A pointer to an interface that will be kept in the global interface table (GIT).
-
Git is a reference to a CComGITPtr object that already exists.
-
dwCookie: An interface pointer identification cookie.
- rv: The CComGITPtr object from which to move data.
Return Value
The modified CComGITPtr object is returned.
You can also read about the memory hierarchy.
Check out most important Git Interview Questions here.
Frequently Asked Questions
Can I use the Global Interface Table in every Windows system?
No! The Global Interface Table is not supported in all Windows systems. Only Windows 95 with DCOM version 1.1, Windows 98, Windows NT 4.0 with Service Pack 3 and later, and Windows 2000 support the global interface table feature.
What is Component Object Model(COM)?
The Component Object Model (COM) software architecture can create applications from binary software components. The supporting architecture known as COM is the building block for higher-level software services. COM is a platform-independent system. It is a simple specification method.
What do you mean by DWORD?
The data type description for Microsoft Windows is called a "dword," which is short for "double word." A dword is a 32-bit unsigned data unit as defined in the file windows.h. It may include an integer value between 0 and 4,294,967,295.
Conclusion
We have discussed the memory management class- CComGITPtr. The CComGITPtr is a memory management class in Active Template Library. The CComGITPtr class provides methods for handling interface pointers and the global interface table (GIT).
We hope this blog has helped you. We recommend you visit our articles on different topics of ATL, such as
🔥 ATL module classes.
🔥 Memory management class-CComHeap and CComHeapPtr.
🔥 Memory management class-CAutoPtr.
If you liked our article, do upvote our article and help other ninjas grow. You can refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and Algorithms, Competitive Programming, System Design, and many more!
Head over to our practice platform Coding Ninjas Studio to practise top problems, attempt mock tests, read interview experiences and interview bundles, follow guided paths for placement preparations, and much more!!
Happy Reading!!