Click to See Complete Forum and Search --> : What is the ATL?


OrangUtanKlaus
February 28th, 2002, 08:24 PM
Can somebody tell me what the ATL is? Has it something to do with the STL(Standard Template Library)?

Klaus

Andreas Masur
February 28th, 2002, 09:03 PM
In short terms ATL is the Active Template Library, a set of template-based C++ classes with which you can easily create small, fast Component Object Model (COM) objects... The classes in the Active Template Library can be broadly divided into three categories: classes that implement COM functionality, classes that act as thin wrappers to the Win32 API and utility classes.

Ciao, Andreas

"Software is like sex, it's better when it's free." - Linus Torvalds

NMTop40
March 1st, 2002, 04:37 AM
The similarity between ATL and STL is that both of them are libraries of templates. Both of them therefore expose all their implementation code, which can be useful for debugging sometimes but generally you don't need to read into it.

ATL is Microsoft-specific, and like Andreas said, has multiple uses, but was originally written for use with COM (Component Object Module), due to the similarity of handling COM objects of different types.

For example, COM objects all use reference counting, and require AddRef() to add a reference and Release() to remove a reference. With ATL, you have a template class CComPtr< > which does that for you, and acts as a smart pointer, overloading the operator -> and also containing a cast to the pointer itself so that you can pass them as a parameter to functions that require a pointer to the interface.

Another template in ATL is the similar CComQIPtr, which is used for safe type-casting using COM's QueryInterface method. This is because COM uses interfaces (abstract base classes with no data members and no private functions), and all interfaces are derived from IUnknown, one of whose methods is QueryInterface. The server deals with components, which are classes that implement the interfaces, and they can implement more than one (multiple inheritance), but the client only deals with single interfaces.

ATL also provides wrapper classes for COM types BSTR (CComBSTR) and VARIANT (CComVariant). There are also _bstr_t and _variant_t wrappers for those types.

Finally, there is also a WTL, which is closely related, and is called the Windows Template Library, which wraps Win32 SDK windows functionality in classes using templates, so you can do GUI programming in C++ without using MFC.


The best things come to those who rate

OrangUtanKlaus
March 1st, 2002, 07:08 AM
Thanks for anwering. But what the hell is COM or a COM-Module. What is it used for. And when do you use such Modules? Is this basic-stuff or experts programmers knowlege?
Klaus

NMTop40
March 1st, 2002, 07:37 AM
It is used on the windows platform only, and is used for writing "components" that perform specified functionality.

It started out as OLE - object linking and embedding - so that you could put a bitmap or an Excel spreadsheet into a Word document. Then the concept grew (as these things do) when people realised the concept was generally a good one.

If you are going to write components using it, you should consider reading Beginning ATL 3 COM by Richard Grimes, published by Wrox. There is another one, something like COM for beginners, published by the Microsoft Corporation.

In both the words beginning/beginner refers to COM, not to programming, and assumes you are a reasonably competent C++ programmer.






The best things come to those who rate

OrangUtanKlaus
March 1st, 2002, 08:36 AM
Thanks a lot.

Zeeshan
March 1st, 2002, 03:07 PM
Currently i m writing a series of tutorial to discuss inner of ATL. Till now i have wrote two artical and currently writing part 3 of it.

ATL Under the Hood Part 1
http://www.codeguru.com/atl/ATL_UnderTheHood_1.html

ATL Under the Hood Part 2
http://www.codeguru.com/atl/ATL_UndertheHood_2.html

Hope you ll get Part 3 soon and get some information about ATL from these tutorials.

Hope it helps.