473,385 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

C++ Proxy Class

hi what is a Proxy class (in reference to C++)
Mar 26 '08 #1
4 11703
Can any one give detail about proxy class...
Mar 26 '08 #2
r035198x
13,262 8TB
hi what is a Proxy class (in reference to C++)
... and what did old google have to say?
Mar 26 '08 #3
r035198x
13,262 8TB
There is northing like proxy class . Proxy would be the name given to the class...can you explain your question in detail...
Do use google for this. Just google for "proxy C++".
Mar 26 '08 #4
weaknessforcats
9,208 Expert Mod 8TB
A proxy class is a stand-in for another class.

Let's suppose you have a class that has a method that takes 60 seconds to complete. That means everytime you call that method, your program waits. But let's also assume you rarely call that method. Let's further assume this method is named Load() and the class is MyClass

Expand|Select|Wrap|Line Numbers
  1. class MyClass
  2. {
  3.     public:
  4.        void Load();   //takes a long time
  5.        void AMethod();
  6.        etc...               //the other methods.
  7. };.
  8.  
The proxy class would look like:
[code=cpp]
class MyClassProxy
{
MyClass* theObject;
public:
MyClassProxy(); : theObject(0) {}
MyClass* operator->();
MyClass& operator*();
};

So when you create a MyClassProxy object, the MyClass* inside is set to zero.

Now you use MyClassProxy objects instead of MyClass objects.

If someone needs the MyClass object, they use the operator-> overload of MyClassProxy. This function just returns the MyClass* if the MyClass object exists otherwise is creates it and calls Load().

Expand|Select|Wrap|Line Numbers
  1. MyClass* MyClassProxy::operator->()
  2. {
  3.    if (!this->theObject)
  4.    {
  5.       theObject = new MyClass;
  6.       theObject->Load();
  7.    }
  8.    return theObject;
  9. };
  10.  
So not until you use the proxy object with the -> operator do you see the 60 seccond delay.

Expand|Select|Wrap|Line Numbers
  1.  
  2. MyClassProxy  p;    //no delay
  3. p->AMethod();         //Here the MyClass object is created
  4.                               //Loaded and the MyClass::AMethod called.
  5.  
Mar 26 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jeff | last post by:
I'm trying to pass a proxy class instance (SWIG generated) of CClass, to a python callback function from C++. The proxy class instance of CClass is created from a pointer to the C++ class CClass....
8
by: SpOiLeR | last post by:
Hello! I have a matrix class like this: class MyObject; // MyMatrix is contains MyObjects class MyMatrix { public: ...
3
by: Benne Smith | last post by:
hi all, i have a webservice with some public classes in it. These classes are visible from my proxy class, generated from wsdl.exe. The problem is, that when i look in the generated proxy class,...
0
by: Paul Hastings | last post by:
Hi All - I am trying to build a Web Service that can be accessed using an Excel spreadsheet. I have been able to do this for relatively simple access to the Web Service. But now I need to...
5
by: HenrySeque | last post by:
I have a webservice and I add a web reference from my web project. I want the proxy class to implements an Interface, but I didn't find the source code of the proxy class and I don't want to...
4
by: Fabio | last post by:
An ASP.NET 2.0 web site contains a web form and a web service. The web form consumes the web service. There is a Book class in the App_Code folder. The web service exposes a method that returns a...
1
by: Arpan | last post by:
A class file named "SecureDBWS.vb" exsting in C:\Inetpub\wwwroot\ASPX\Business folder has the following code: Imports System Imports System.Data Imports System.Data.SqlClient Imports...
0
by: Magnus Schuster | last post by:
Hello, I have written the following small proxy class which I expect to pass all function calls to the 'original' object: --- BEGIN --- class proxy(object): def __init__( self, subject ):...
0
by: Magnus Schuster | last post by:
With this explanation the behaviour is absolutely clear. Can I find some documentation anywhere containing more background information how magic functions are resolved? I haven't been successful...
2
by: Dinsdale | last post by:
We have created a object library that implements the INotifyPropertyChanged.PropertyChanged to bubble changes up to higher level classes. For instance, we have a person class that can have...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.