473,396 Members | 2,011 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,396 software developers and data experts.

Many Text Relocations In Shared Object

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_iterator it;

it = m_mapMsgFactories.find( msgType );

if ( it != m_mapMsgFactories.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_mapMsgFactories[ msgType ] = pMsgFactory;
}

protected:

MsgFactoryTable() {}

private:

std::map< unsigned char, MsgFactory * > m_mapMsgFactories; /*!<
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_iterator it;

it = m_mapMsgFactories.find( msgType );

if ( it != m_mapMsgFactories.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_mapMsgFactories[ msgType ] = pMsgFactory;
}

protected:

MsgFactoryTable() {}

private:

std::map< unsigned char, MsgFactory * > m_mapMsgFactories; /*!<
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_IterMapFactory( IterMap::PROTOCOL );
}

------------

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.
Jul 22 '05 #1
1 1630

"Gregg Altschul" <ga*******@factset.com> wrote in message
news:2c*************************@posting.google.co m...
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
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
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...
0
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...
33
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...
6
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
2
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...
10
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....
13
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. ...
4
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...
4
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...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
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,...
0
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...
0
tracyyun
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...

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.