I have a Shared Object which its sole purpose is to create objects of
a certain type and return a pointer to the object to the user.
Therefore, the user becomes the owner of this object and is resposible
for deleting it. It utilizes the factory pattern to create the
objects. The problem is that I am finding it nearly impossible to get
rid of my Text Relocations. I'm using the -Kpic and -ztext options
(which, of course, makes my link-edit fail). Here's the code:
MsgFactory.h
namespace MDS
{
class Message;
}
// Message factory interface
class MsgFactory
{
public:
MsgFactory() {};
virtual ~MsgFactory() {};
virtual MDS::Message* getNewMsg() = 0;
private:
};
// Actual message factory implementation
template< typename MSG_TYPE >
class MsgFactoryImpl : public MsgFactory
{
public:
//! MsgFactoryImpl constructs the actual message factory and
adds itself to the MsgFactoryTable
/*!
\param cId unsigned char that identifies the message's id
*/
MsgFactoryImpl( unsigned char cId )
{
MsgFactoryTable ::getInstance() .addMsgFactory( cId, this );
};
virtual ~MsgFactoryImpl () {}; /*!< DESTRUCTOR */
//! getNewMessage creates a message of the templated type
/*!
\returns Message* to the new empty message
*/
MDS::Message *getNewMsg()
{
// create and return the new Message*
MSG_TYPE *pMsg = new MSG_TYPE;
return pMsg;
}
private:
};
// Table of MsgFactory pointers - keeps a map of global Message
Factories
// MsgFactoryTable is a singleton
class MsgFactoryTable
{
public:
//! getInstance gets the single object
/*!
\returns MsgFactoryTable &
*/
//static MsgFactoryTable & getInstance();
//! getMsgFactory retrieves an actual Message Factory
/*!
\param msgType unsigned char that identifies the message factory's id
\returns MsgFactory* to the actual MsgFactoryImpl
*/
MsgFactory * getMsgFactory( unsigned char msgType ) const
{
std::map< unsigned char, MsgFactory * >::const_iterat or it;
it = m_mapMsgFactori es.find( msgType );
if ( it != m_mapMsgFactori es.end() )
{
// return the message factory
return it -> second;
}
else
{
return NULL;
}
}
//! addMsgFactory adds a factory to the map
/*!
\param msgType unsigned char that that identifies the message
factory's id
\param pMsgFactory MsgFactory* that points to the actual message
factory
*/
void addMsgFactory( unsigned char msgType, MsgFactory *
pMsgFactory )
{
// add the factory to the map
m_mapMsgFactori es[ msgType ] = pMsgFactory;
}
protected:
MsgFactoryTable () {}
private:
std::map< unsigned char, MsgFactory * > m_mapMsgFactori es; /*!<
map to store the MsgFactory objects in */
};
//} // namespace MDS
#endif /* MDSMsgFactory_H _ */
-------------------
MsgFactory.cpp
namespace MDS
{
class Message;
}
// Message factory interface
class MsgFactory
{
public:
MsgFactory() {};
virtual ~MsgFactory() {};
virtual MDS::Message* getNewMsg() = 0;
private:
};
// Actual message factory implementation
template< typename MSG_TYPE >
class MsgFactoryImpl : public MsgFactory
{
public:
//! MsgFactoryImpl constructs the actual message factory and
adds itself to the MsgFactoryTable
/*!
\param cId unsigned char that identifies the message's id
*/
MsgFactoryImpl( unsigned char cId )
{
//std::cout << "Creating Factory with ID" << cId << std::endl;
//MsgFactoryTable oTable = MsgFactoryTable ::getInstance() ;
//MsgFactoryTable ::getInstance() .addMsgFactory( cId, this );
};
virtual ~MsgFactoryImpl () {}; /*!< DESTRUCTOR */
//! getNewMessage creates a message of the templated type
/*!
\returns Message* to the new empty message
*/
MDS::Message *getNewMsg()
{
// create and return the new Message*
MSG_TYPE *pMsg = new MSG_TYPE;
return pMsg;
}
private:
};
// Table of MsgFactory pointers - keeps a map of global Message
Factories
// MsgFactoryTable is a singleton
class MsgFactoryTable
{
public:
//! getInstance gets the single object
/*!
\returns MsgFactoryTable &
*/
//static MsgFactoryTable & getInstance();
//! getMsgFactory retrieves an actual Message Factory
/*!
\param msgType unsigned char that identifies the message factory's id
\returns MsgFactory* to the actual MsgFactoryImpl
*/
MsgFactory * getMsgFactory( unsigned char msgType ) const
{
std::map< unsigned char, MsgFactory * >::const_iterat or it;
it = m_mapMsgFactori es.find( msgType );
if ( it != m_mapMsgFactori es.end() )
{
// return the message factory
return it -> second;
}
else
{
return NULL;
}
}
//! addMsgFactory adds a factory to the map
/*!
\param msgType unsigned char that that identifies the message
factory's id
\param pMsgFactory MsgFactory* that points to the actual message
factory
*/
void addMsgFactory( unsigned char msgType, MsgFactory *
pMsgFactory )
{
// add the factory to the map
m_mapMsgFactori es[ msgType ] = pMsgFactory;
}
protected:
MsgFactoryTable () {}
private:
std::map< unsigned char, MsgFactory * > m_mapMsgFactori es; /*!<
map to store the MsgFactory objects in */
};
//} // namespace MDS
#endif /* MDSMsgFactory_H _ */
-----------
IterMapFactory. cpp
#include "MsgFactory .h"
#include "IterMap.h"
namespace MDS
{
// create the global message factory
MsgFactoryImpl< IterMap > g_IterMapFactor y( IterMap::PROTOC OL );
}
------------
If I get rid of the MsgFactoryImpl instance in IterMapFactory. cxx then
all of my text relocations go away altogether. If I leave that line in
and comment out the getNewMsg function in the MsgFactory and
MsgFactoryImpl classes in MsgFactory.h then I get only a few text
relocations.
I thoroughly appreciate any help I can get. 1 1647
"Gregg Altschul" <ga*******@fact set.com> wrote in message
news:2c******** *************** **@posting.goog le.com... I have a Shared Object which its sole purpose is to create objects of a certain type and return a pointer to the object to the user. Therefore, the user becomes the owner of this object and is resposible for deleting it. It utilizes the factory pattern to create the objects. The problem is that I am finding it nearly impossible to get rid of my Text Relocations. I'm using the -Kpic and -ztext options (which, of course, makes my link-edit fail). Here's the code:
Perhaps others understand what you mean, but...what's a "Text Relocation"?
-Howard This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phil |
last post by:
I realize this is the php group, but I have a question that recurses
back to my php install.
My objective is a pure 64 bit shared object installation of php 5.0 on
UltraSparc Solaris 9 compiled with the Sun Compiler version 8.
My problem is that EVERYTHING builds great EXCEPT that the 6b
distribution of JPEG will NOT build a shared object, thus gd cannot
include support for JPEG, thus php loses that functionality.
|
by: Srijit Kumar Bhadra |
last post by:
Hello,
Here is some sample code with pywin32 build 203 and ctypes 0.9.6.
Best regards,
/Srijit
File: SharedMemCreate_Mutex_win32all.py
# This application should be used with SharedMemAccess_Mutex_ctypes.py
or SharedMemAccess_Mutex_win32all.py
|
by: MLH |
last post by:
I've read some posts indicating that having tons of GV's in
an Access app is a bad idea. Personally, I love GVs and I
use them (possibly abuse them) all the time for everything
imaginable - have been for years. If the machine has memory
to spare and windows can use it - I'm thinking "Why not?"
I was wondering what some of you have to say about that,
particularly any severe "gotchas" you've had the unfortunate
experience to contend with.
|
by: pankaj.khandelwal |
last post by:
Hi,
How can I bundle a text/gif file in the shared object. Basically I want
to read the content of this text file but I cannot have it seperately
on the disc.
Any clues. ?
Pankaj
|
by: tshad |
last post by:
I have a program I am trying to compile into a dll and am getting a bunch
of: the following errors:
error BC30469: Reference to a non-shared member requires an object
reference.
At first, I thought it was because I had the sub set as shared, but I get
the same error if it take the Shared out.
What is causing these errors?
| |
by: One Handed Man [ OHM ] |
last post by:
If this is duplicated, I'm sorry because I cant find the original post I
made today
Anyway . .
Now its my turn to ask a question
I want to develop an app which will run in the system tray. How can I do
this?
|
by: Nak |
last post by:
Hi there,
In VB6 if I wanted to make a shared application so to speak I would
create an ActiveX EXE. This would allow me to expose objects of the
application but only have 1 instance loaded. What is the equivilent in
VB.NET? Would I create a normal assembly that can be communicated with
using remoting? or are there other ways?
Thanks in advance.
|
by: Jan Nielsen |
last post by:
Hi all
I'm a former Access developer who would like to implement a many-to-many
relation in about the same way you do in Access: With a subform and a combo
box.
Is it possible to use a combobox in a datagrid?
Any other suggestions/articles on how to implement many-many relations in
the frontend (which of course are 2 one-many relations)?
|
by: Ken Soenen |
last post by:
The code below illustrates my problem which is: I'm trying to access the
TEXT from TextBox1 which is on Form1. Line "aa = Form1.TextBox1.Text"
produces the error--Reference to a non-shared member requires an object
reference". Being new to VB.NET, this doesn't say much to me, nor does the
Show Task Help for this particular msg. Just one example would make all the
difference in the world. Can somebody point me in the right direction??
...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |