Please do not address emails intended for the list directly to my email
address. I'm already subscribed to the list, so emailing directly to me
only results in multiple copies.
You cannot create any Xerces or Xalan objects before you call the Xerces
and Xalan initialization functions. Nor can you destroy any instances
after you've called the termination functions. This is well-documented,
and I have stated in previous exchanges we've had on this topic. If you're
going to insist on calling these functions in your constructor and
destructor, then you must use pointers to instances. You must also make
sure you create the instances after you initialize, and destroy them before
you terminate
It's better to call the initialization functions after your process starts,
but before you do anything processing with Xerces or Xalan. Then, once
you've finished using Xerces and Xalan, you should call the terminate
functions. Of course, if you're unwilling to impose this burden on your
users, then you can't do this, and you'll have to manage this in your
constructor.
Dave
"Tankel, Ifat"
<[EMAIL PROTECTED] To: "'David N
Bertoni/Cambridge/IBM'" <[EMAIL PROTECTED]>,
mverse.com> "'[email protected]'"
<[email protected]>
cc:
06/30/2002 01:51 Subject: creating objects (but
not using) before calling XMLPlatformUtils:
AM initialize() and
XPathEValuator:initialize()
Hi
I have created a class myDom.
This class is to be used by other classes when they need to access/modify
data written in xml format (file or buffer).
This myDom class call XMLPlatformUtils:initialize() and
XPathEValuator:initialize() in its constructor.
This myDom class call XMLPlatformUtils:terminate() and
XPathEValuator:terminate() in its destructor.
But now
If I follow your advice and I will create
DOMParser _domParser;
XercesDOMSupport _domSupport;
XercesParserLiaison _parserLiaison;
(instead of
DOMParser * _domParser;
XercesDOMSupport * _domSupport;
XercesParserLiaison * _parserLiaison;
and then creating them on the heap)
It means that when I create an instance of myDom class ( on the heap or on
the stuck) the constructor of each of these data member is called before
call to XMLPlatformUtils:initialize() and XPathEValuator:initialize().
and when this myDom instance is to be destroyed (by delete or by the
compiler) the destructor of each of these data member is called after
call to XMLPlatformUtils:terminate() and XPathEValuator:terminate()
I have a static counter in myDom class that make sure that these initialize
and terminate are called only once.
Should I call _domParser.reset() _domSupport.reset() _parserLiaison.reset
() in my destructor before calling XMLPlatformUtils:terminate() and
XPathEValuator:terminate()?
will I have problem with this myDom class design?
I prefers not to create a static methods in myDom class that the "user" of
myDom class will have to call before and after it use the myDom class.
Ifat
-----Original Message-----
From: David N Bertoni/Cambridge/IBM [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 27, 2002 6:20 PM
To: '[email protected]'
Subject: Re: creating objects on the heap
Yes, you can create them on the heap. Often, it's more appropriate to
create small objects on the stack, as it reduces worries about memory
leaks, and it's more efficient.
If you want this call to be read/write thread-safe, you'll have to
synchronize access to it yourself. If you want it to be thread-safe for
reading, you should not have a problem.
Dave
"Tankel, Ifat"
<[EMAIL PROTECTED] To:
"'[email protected]'" <[email protected]>
mverse.com> cc: (bcc: David N
Bertoni/Cambridge/IBM)
Subject: creating objects on
the heap
06/27/2002 05:34
AM
Hi
I have created a class myDom.
This class is to be used by other classes when they need to access/modify
data written in xml format (file or buffer).
I whant to create private members which are to be created on the heap
DOMParser * _domParser;
XercesDOMSupport * _domSupport;
XercesParserLiaison * _parserLiaison;
to use them in myDom methods
I sow that in the samples you usualy create them on the stack
I there any limitation not to create them on the heap?
way?
I will be glad if some one will help me soon
Ifat
ps this class need to be thread safe
<<...OLE_Obj...>>
[EMAIL PROTECTED]
Comverse Divisional Developer
EMEA1 E7-General 3log
03-6454768
053-762891