Click here to Skip to main content
15,891,529 members
Articles / Programming Languages / C++/CLI

Bridge Pattern - Bridging the gap between Interface and Implementation

Rate me:
Please Sign up or sign in to vote.
4.60/5 (26 votes)
8 Jan 2001 198.3K   686   83  
This article discusses the Bridge Pattern, what it is, why and when it is needed.
// ImageImp.h : interface of the CImageImp class
//
/////////////////////////////////////////////////////////////////////////////

#ifndef IMAGE_IMP
#define IMAGE_IMP

//	Predefined constants 
#ifndef SUCCESS 
#define SUCCESS		0
#endif

#ifndef FAILURE
#define FAILURE		-1
#endif

class CImageImp : public CObject
{
	// Constructor / Destructor
	public :
		CImageImp();
		virtual ~CImageImp();

	// List of Services to be defined by the derived class
	public :
		virtual INT		InitImageInfo( LPSTR )					= 0;
		virtual INT		GetNumColors( LPSTR = NULL )			= 0;
		virtual LPSTR	GetColorTable()							= 0;
		virtual BOOL	PaintImage( CWnd *, CRect * )			= 0;
		virtual BOOL	CreateImagePalette()						= 0;
		DECLARE_DYNAMIC( CImageImp )

	// Attributes
	public :
		LPBYTE				m_pImage;
		LONG					m_lNormalWidth;
		LONG					m_lNormalHeight;
};

// CWinImp class declaration
class CWinImp : public CImageImp
{
	// Constructor / Destructor
	public :
		CWinImp();
		virtual ~CWinImp();

	// Services to be defined by this class
	public :
		INT		InitImageInfo( LPSTR );
		INT		GetNumColors( LPSTR = NULL );
		LPSTR		GetColorTable();
		BOOL		PaintImage( CWnd *, CRect * );
		BOOL		CreateImagePalette();
		DECLARE_DYNCREATE( CWinImp )

	// Attributes
	protected :
		BYTE					* m_pBmi;
		CPalette				* m_pPalette;
};
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Switzerland Switzerland
Kulathu Sarma is working as a Technology Manager for GoldAvenue, a company based in Geneva, Switzerland and responsible for supporting e-business initiatives of GoldAvenue in B2B and B2C Sectors. He has been programming in C/C++ for 9 years and actively working on Patterns for the past 5 years.

Comments and Discussions