|
std::copy is probably your best bet. Using it is going to ensure that your compiler has the best chance of optimising (no post increments or missing consts on iterators) and is easy to read for code maintainers.
If you're worried about this operation, and it's a possible bottleneck it is worth profiling the various options. Because seemingly obvious optimisations (like calling reserve() on the vector) might not do as much to help as you think. See the article by Andrew Koenig and Barbara E. Moo "Are Vectors Really Fastest?" published in the August 2004 issue of the C/C++ Users Journal.
memcpy is only an option if your data elements are POD (Plain Old Data), but even then in some (most?) situations the code that std::copy will generate is exactly the same as the memcpy code.
Custom STL allocators might help if your objects are reasonably small (a few bytes) - although it would be rare that this would be a preformance issue.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
|
memcpy() ?
TOXCCT >>> GEII power
|
|
|
|
|
Hi,
can I use the WTL menu (with bitmap buttons) in an MFC Application?
(I need a bitmap menu, with some additional features, that would best work in both MFC and ATL/WTL components)
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist Fold With Us! || Agile Programming | doxygen
|
|
|
|
|
Hi,
I'm developing an ATL Server Web Service and I'm having this problem: I perform a stress test (50 concurrent connections) for 15 minutes, and after the test is finished I find that the performance monitor (in the web service object) registers more connections than 50, but the worst part is that these connections don't go totally down. Almost always the fall slowly until they reach 20 connections and then they stay there (I've left the server on for one or two days, but the number of connections don't fall to zero).
These are TCP connections I suppose, and from inside my app I just have access to the http layer. I think that IIS (I'm working with IIS 5.0 and Win2k Server) manages these connections, but I don't know if that's exactly like that. I would appreciate a lot to know if anyone has had this (kind of)problem before, and in that case what was happening.
Thanks,
Federico
|
|
|
|
|
I have two COM class in ATL/DLL:
1º
class Connection
{
interface IConnection
Open(BSTR PAthName)
Close()
//Other methods beginTrans commit roollback.. properties..timeout type etc..
public:
Connection(){//initialize};
StructDB getHandleDB();//return private var m_handleDB
//+++ other methods & properties
private:
StructDB m_handleDB;
//+++ other vars...
}
2º
class Recordset
{
interface IRecordset
Open(BSTR StrSQL, IConnection *Connection)
Close()
//Other properties and methods fields value RecordsCount ..etc
public: //etc
private: //etc
}
I compile the ATL/DLL , I from VB 6 IDE , Refernce my DLL and I write this code:
'VB COde..
dim mConnectionDB as MyLib.Connection
dim rs as MyLib.Recordset
set mConnectionDB=new Connection
mConnectionDB.Open "Database.mydb"
set rs=new Recordset
rs.Open "Select * from Customers",mConnectionDB
rs.close
mConnectionDB.Close
The question is... How in the method Open the recordset class, can I access the method StructDB getHandleDB();//return private var m_handleDB ???????
I don't want put property interface return the handle... this property not necesary from VB.
If I used to CCOmObject I have got new instance the Connection and handle is NULL.
Help ME!! please
|
|
|
|
|
I find a solution!!! I have created a private interface!! Only visible for ATL/DLL.
|
|
|
|
|
Hi,
This following code in a console application:
CoInitialize(0);
HRESULT hr;
SHDocVw::IShellWindowsPtr spSHWinds;
hr = spSHWinds.CreateInstance (__uuidof(SHDocVw::ShellWindows));
====> Returns 0x0x80040154 - Class not registered.
Can someone please help me why I am getting this error?
Any help would be greatly appreciated.
SenPy
|
|
|
|
|
Try registering SHDOCVW.DLL using regsvr32 utility and then running your app.
-------------------------
Have a great day ahead!
Regards,
Sohail Kadiwala
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I create ATL component with a number of methods. Some of them run perform long operations, and I need send to client application status of this. How do I have to add event to my ATL and listen it in a client application ?
|
|
|
|
|
Hello Dudic,
My advise is to create a separate thread in your COM Object to perform the long operations. As and when a change in status occurs in your COM object, you fire an event to your client app.
There are several points you need to note about achieving the above mentioned design :
1. Your thread must be a COM thread. That is, it must call CoInitialize() on start up and call CoUninitialize() just before termination.
2. The event handler interface pointer of your client (which are passed to you when your client connects with your COM Object's connection points) must be marshalled to your COM Object. They -CANNOT- be passed to your thread by simple copying.
I'm going to write an article on COM threading soon and I'll keep you posted when I do.
Best Regards,
Bio.
|
|
|
|
|
dudic wrote:
I create ATL component with a number of methods. Some of them run perform long operations, and I need send to client application status of this. How do I have to add event to my ATL and listen it in a client application ?
yeah Buddy,
you have to implement IConnectionPoint Interface in you class to raise event.
Follow these step->
1.add a simpleATL object using Insert|newATlobject
chose Simple Object and press NEXT
you find the Property Sheet there
#1 property sheet for name
Give the name to you object say ObjectEvent.
#2 Attribute
Check the boc for IConnectionPoint interface.
then press ok.
you will see two interface for your class
interface ObjectEvent
dispinterface _IObjectEvent
add method in _IObjectEvent thorough class wizard.
like
void MyEvent();
and implement this Connection point in the iObjectEvnt Interface.
you can get option by right clicking on class of interface.
and for notifying other user about event
you got the Event in you Interface class like this
FIRE_MyEvent()
and by calling this function you can fire event that can be handle by clientapplication.
dudic wrote:
listen it in a client application
sorry i don't have any knowledge about how to handle event in VC++ based application ,because i used to test application with VB.
i hope any good programmer will help you in this matter
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Is it better to write controls in ATL of MFC ActiveX? What are the pros and cons of each?
|
|
|
|
|
As I understand it, ATL was originally designed as a more efficient way of producing these, so I'd go with ATL.
Kevin
|
|
|
|
|
Hi,
Here is the part of the EXE code:
if (FAILED (CoInitialize (NULL)))
{
return FALSE;
}
...
...
HRESULT hr;
IWebBrowser2* pWebBrowser = NULL;
hr = CoCreateInstance (CLSID_InternetExplorer, NULL,
CLSCTX_LOCAL_SERVER, IID_IWebBrowser2,
(LPVOID*)&pWebBrowser);
====> hr is 0x80070005 - Access is denied.
This is happening only with Windows XP/SP2. On the same PC with SP1, it works fine also it works fine on W2K.
Can someone PLEASE help me to solve this issue?
Thanks
SenPy
|
|
|
|
|
|
Hi,
I am trying to navigate to a particular web site and populate the web form fields from my MFC application.
BTW, this code works fine on W2K and XP/SP1.
Regards
SenPy
|
|
|
|
|
I have a problem, I am developing a ATL server/DLL of SQLite Database engine. I have created two COM class, (Connection and Recordset) to I can used how ADO tecnologies, but I haven't install MDAC ...
The problem is in class Recordset. I have MEthod STDMETHODIMP CRecordset::Open(BSTR SelectSQL, IConnection *Connection), because I have not access to public method class C++ CConnection, getHandleDatabase() that return handle to database opened. I have try CComObject<cconnection>* Conexion;
CComObject<cconnection>::CreateInstance(&Conexion);
Conexion->getHandleDatabase();
but handle = NULL ,,,
How I can access object C++ method of interface that pass how parameter 'IConnection *Connection'.
Sorry for my bad english
|
|
|
|
|
How can i check if a CLSID is valid or not without actually creating an object i.e without calling CoCreateInstance
and if CLSIDFromAppID function fails is it necessary that the AppID is wrong
thanks
|
|
|
|
|
You would need to replicate the steps that COM takes when looking for a COM server:- Convert the CLSID to a string
- look for a key with that name under HKCR\CLSID
- look for an InprocServer32 key (or LocalServe32 depending on the server type) key under there
- Read the default value of that key, which holds the full path to the server
- See if that file exists
- For in-proc servers, see if that is a DLL that exports DllGetClassObject().
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
|
|
|
|
|
Estamos identificando um profissional para atuar em nossa empresa com o seguinte perfil :
Programação em Visual C++ utilizando WTL;
Bons conhecimentos em programação Internet.
Disponibilidade para início imediato.
Os interessados deverão enviar currículo para rh@techway.com.br
Solange Gomes
Solange Gomes
|
|
|
|
|
inglês somente, por favor
--
Suche gut gebauten Achtzehn bis Dreißigjährigen zum Schlachten.
Der Metzgermeister
|
|
|
|
|
I need to wrap a native class for using it in C#
the class contain CString objects.
in old MC++ ver 2003 i write somthing like :
__property String * get_ImageName ()
{
return mBillPopJobParameters-> m_ImageName ;
}
__property void set_ImageName (String * pValue )
{
mBillPopJobParameters-> m_ImageName = pValue;
}
(m_ImageName is a CString.)
and it work ok.
when i try to use it in C++/CLI
property String^ ImageName
{
String^ get()
{
return mPrintSetParameters->m_ImageName ;
}
void set(String^ pValue)
{
mPrintSetParameters-> m_ImageName = pValue;
}
}
i get error that it can not convert from CString to String
any one know how to it right ?
Thanks.
Avraham Cohen.
|
|
|
|
|
Guys,
Newbie question, so bear with me, this is my first Windoze app ..
Part of a caf billing application, I need to lock the PC screen untill a signal is sent by the console/user name-password entered/time code entered ...etc.
I would ideally like to achive this without writing the client as a shell replacement. I had a look at HtmlLayout, and that sounds plausable.
Any ideas/views/directions ..etc ?
Thanks in advance.
Ahmad Ibrahim.
|
|
|
|
|
you can use the someting like a desktop switching like the one made by Nnamdi Onyeyiri [^] but with some minor modifications like remove 2 of the "shells", change the swicthing event to work with remote control... etc ...
I think is the simple way ...
and is .net ...
.NET is the next step to the end of programmer
|
|
|
|