DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Objects and pointers

  1. #1
    Join Date
    May 2004
    Posts
    242

    Objects and pointers

    Hello,

    I have the following code :-

    ...
    RWCollectable* SpotRateReconciler::getHashKey(DisplayObject* pObject)
    {
    SpotRate* pSpotRate = (SpotRate*)pObject;
    return new RWCollectableString(pSpotRate->getBASE_CCY() + ":" + pSpotRate->getCCY());
    }
    ...

    DisplayObject* SpotRateReconciler::createObject()
    {
    SpotRate* pSpotRate = new SpotRate;

    pSpotRate->setBASE_CCY("GBP");
    pSpotRate->setLOCATION_ID("LDN");

    return pSpotRate;
    }
    ...


    I would like to access SpotRate methods from createObject(), e.g. pSpotRate ->getCCY(), however, as you can see DisplayObject* pObject isn't being passed to createObject() and I'm not in a position to change this or any other function definition (those are APIs provided by a third party vendor).

    The whole idea is getHashKey() shows the current details in the database and createObject() creates a new object of SpotRate. I need to access the old values from within getHashKey() before the 'new' takes place.

    You may ask why not do the whole processing within getHashKey() ? The reason for this is because this method is being called a number of times and if I need to do my processing only once. I know I can use a global counter, e.g. :-
    ...
    counter = 0;
    ...
    RWCollectable* SpotRateReconciler::getHashKey(DisplayObject* pObject)
    {
    // current code
    if (++counter == 1)
    {
    // do processing
    }
    }

    However, this is probably not very nice.

    Can someone please help ?

    Thanks,

    Imanuel.

  2. #2
    Join Date
    Nov 2003
    Posts
    4,118
    Your question isn't very clear. Particulalrly, which functions are yours and which ones are RogueWave's? Anyway, why not keep a pointer to the object you need in a separate block and then access that pointer? It should point to the same object until you delete it. In other words, cache the object locally in the program itself.
    Danny Kalev

Similar Threads

  1. Replies: 3
    Last Post: 06-09-2007, 02:54 AM
  2. Exception & stack unwinding
    By rssmps in forum C++
    Replies: 1
    Last Post: 01-19-2007, 04:46 PM
  3. Replies: 1
    Last Post: 11-26-2005, 03:44 PM
  4. Linking objects with pointers
    By process in forum C++
    Replies: 3
    Last Post: 03-03-2005, 06:43 PM
  5. Permissions on Objects
    By Xin Li in forum Database
    Replies: 4
    Last Post: 01-02-2001, 05:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center