Design Pattern Examples
Overview of object-oriented design patterns
Proxy_Class Class Reference

The proxy class that implements the IWorkByProxy. More...

Inheritance diagram for Proxy_Class:
Inheritance graph
Collaboration diagram for Proxy_Class:
Collaboration graph

Public Member Functions

std::string DoWork (std::string someArgument)
 Do some work on a std::string.
 
- Public Member Functions inherited from IWorkByProxy
virtual ~IWorkByProxy ()
 
virtual std::string DoWork (std::string someArgument)=0
 Does some work on the given argument and returns a new std::string.
 

Private Member Functions

DesignPatternExamples_cpp::IWorkByProxy_GetRealClass ()
 Helper method to retrieve the one and only instance of the real class. This hides the details of instantiating the real class.
 

Private Attributes

std::unique_ptr< DesignPatternExamples_cpp::IWorkByProxy_realClassInstance
 The one and only instance of the real class associated with this proxy class instance.
 

Detailed Description

The proxy class that implements the IWorkByProxy.

Definition at line 54 of file Proxy_Class.cpp.

Member Function Documentation

◆ _GetRealClass()

DesignPatternExamples_cpp::IWorkByProxy * _GetRealClass ( )
inlineprivate

Helper method to retrieve the one and only instance of the real class. This hides the details of instantiating the real class.

Returns
A single instance of the real class represented by the IWorkByProxy interface.

Definition at line 67 of file Proxy_Class.cpp.

References Proxy_Class::_realClassInstance.

Referenced by Proxy_Class::DoWork().

◆ DoWork()

std::string DoWork ( std::string  someArgument)
inlinevirtual

Do some work on a std::string.

Parameters
someArgumentA std::string to work on.
Returns
Returns a new std::string.

The real class this proxy represents is not instantiated until this method is called even though the proxy class has been instantiated. When this method is called for the first time, the real class is instantiated, incurring a performance penalty only on the first call.

Implements IWorkByProxy.

Definition at line 95 of file Proxy_Class.cpp.

References Proxy_Class::_GetRealClass(), and IWorkByProxy::DoWork().

Member Data Documentation

◆ _realClassInstance

std::unique_ptr<DesignPatternExamples_cpp::IWorkByProxy> _realClassInstance
private

The one and only instance of the real class associated with this proxy class instance.

Definition at line 58 of file Proxy_Class.cpp.

Referenced by Proxy_Class::_GetRealClass().


The documentation for this class was generated from the following file: