Table of contents
1.
Introduction
2.
Introduction to ATL
3.
What is COM?
4.
Using a Template Library
5.
Scope of ATL
6.
Recommendations for Choosing Between ATL and MFC
6.1.
Using ATL
6.2.
Using MFC
6.3.
Using ATL in an MFC Project
7.
Frequently Asked Questions
7.1.
What are ATL and MFC?
7.2.
What is ATL in programming?
7.3.
What is the class in C++?
7.4.
What is a template class in C++?
8.
Conclusion
Last Updated: Mar 27, 2024

What is an Active Template Library?

Author Aditi
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Have you worked with C++ programming language? Do you want to learn something new in C++?

Then you have come to the right place. This article is focused on one of the template libraries of the C++ programming language, i.e., Active Template Library. This library allows an easy way to create small and fast COM objects. It is a template-based set of C++ classes. It has various features and can be used to create different objects. Let's dive into the article to know more.

active template library

Introduction to ATL

ATL stands for Active Template Library. It is a template-based set of C++ classes. You can easily create small and fast COM objects. Here COM stands for Component Object Model. ATL supports key features of COM. Those features include stock implementations of IUnknown, IDispatch, IClassFactory, and IClassFactory2. The features also include the following:-

  • dual interfaces, 
  • connection points, 
  • tear-off interfaces, 
  • standard COM enumerator interfaces and 
  • ActiveX controls.

 

ATL code is used to create different objects. They are as follows:-

  • single-threaded objects
  • free-threaded model objects
  • apartment-model objects
  • both apartment-model and free-threaded objects

What is COM?

COM stands for Component Object Model. It is the famous TLA (three-letter acronym) that is present in Windows everywhere now. Various technologies are coming based on COM. COM documentation contains many terms like COM object, server, interface, etc. But what is COM exactly?

COM is a technique for exchanging binary code between programs and languages. It is unlike the C++ method, which encourages source code reuse. ATL is the ideal example of this. Reusing code at the source level is effective, but only in C++. Along with the possibility of name collisions, it increases bloat in your project. This bloat is caused because of having several copies of the same code. This is important to know before you move forward in the article.

Using a Template Library

A template is similar to macros. A template expands when called in the written code, similar to what a macro does (with the proper parameter substitution). A template, however, takes a step further. It enables the development of new classes based on types supplied as parameters. These new classes put the operation specified in your template code into type-safe practice.

In contrast to standard C++ class libraries, template libraries like ATL are often only provided as source code (or as source code with some little runtime assistance). They are not inherently or necessarily hierarchical in design. To obtain the functionality you require, you instantiate a class from a template rather than deriving from a class.

Scope of ATL

Easy creation of COM objects, ActiveX controls, and Automation servers is possible using ATL. Many of the basic COM interfaces have built-in support in ATL. You must include the ATL source code that is provided with your application. ATL provides a DLL (atl90.dll) with code that can be shared among components. But this DLL is not required.

Recommendations for Choosing Between ATL and MFC

There are two approaches available for developing apps and components: 

  • ATL (the Active Template Library)
  • MFC (the Microsoft Foundation Class Library).

Using ATL

ATL is a fast and simple approach to building a C++ COM component with a small footprint. Develop a control using ATL if you don't require all of the built-in features that MFC automatically offers.

Using MFC

MFC can construct whole apps, active documents, and ActiveX controls. If you have already developed a control using MFC, you might wish to continue working with it. When developing a new control, consider using ATL if you don't require all of MFC's built-in features.

Using ATL in an MFC Project

Running a wizard allows you to add support to an existing MFC project for using ATL.

Frequently Asked Questions

What are ATL and MFC?

MFC is Microsoft Foundation Classes. It provides a C++ object-oriented wrapper over Win32 to rapidly develop native desktop applications. ATL is the Active Template Library. It is a wrapper library that simplifies COM development. It is used extensively for creating ActiveX controls.

What is ATL in programming?

The Active Template Library (ATL) is a set of template-based C++ classes. It allows you to create small and fast Component Object Model (COM) objects.

What is the class in C++?

In C++, a class is a user-defined type or data structure that includes data and functions as members. Its access is controlled by the three access specifiers: private, protected, and public.

What is a template class in C++?

Templates in c++ are defined as a blueprint or formula for creating a generic class or a function. Generic Programming is an approach where parameters are generic types in algorithms, and it works for various data types. A template in C++ is a straightforward yet effective tool.

Conclusion

This complete article has helped us to learn about all the concepts of Active Template Library. We have learned about ATL, ways to use template libraries, and the scope of ATL.

We hope this blog has helped you enhance your  ATL of C++ programming language knowledge. Check out our articles to know more about the classes & objectsintroduction to templates, and STL in C++. Practice makes a man perfect. To practice and improve yourself in the interview, you can check out Top 100 SQL problemsInterview experienceCoding interview questions, and the Ultimate guide path for interviews.

Do upvote our blog to help other ninjas grow. Happy Coding!

thank you image
Live masterclass