|
Wow, Patrick in the first listing of errors #1 and #2 are beginner C++ compiler errors. Also you voted my post as not helpful so I have no motivation to help you. However you need to help yourself first by learning how to program in C++ if you intend to, well, program in C++.
led mike
|
|
|
|
|
Led Mike, I'm sorry if you didn't like me voting your response as not useful, but since it wasn't an answer, I'm afraid it really wasn't useful. That being said, I do appreciate any assistance. Also, I appreciate that people do in take the time to read and help other people out with their problems.
Now, with all of that being said, in my (very long) experience with C++ compilers I've found that when the compiler gets confused it tends to spit out trash for error messages. You mentioned that the errors are "novice" mistakes (since they are referring to semicolons and such). I guarantee that there are no semicolons missing. I know this because when I take out my function calls (listed above, semicolons and all) all the troubles go away. (I should point out that in example 2 I forgot to post the deceleration of my private member variable, it is in the code though, as in example 1). Also, as in the code shown above, the variables that are claimed by the compiler to not be declared in fact are, but seem to be ignored by the compiler. This is actually why I didn't give any errors in my first post and why I only summarized the problem (I figured a print out of nonsensical compiler errors would be a waste of disk space). All of this led me to believe that when a class uses a template that it can't have additional parameters added to it lightly, although I highly doubt that it's impossible.
|
|
|
|
|
Patrick G wrote: but since it wasn't an answer, I'm afraid it really wasn't useful.
But David's post was an answer? Whatever dude, good luck.
DavidCrow wrote: What does line 125 (and possibly the few preceding it) of ReactorServer.cpp look like?
led mike
|
|
|
|
|
Patrick G wrote: Error 1 error C2039: 'setCommSystem' : is not a member of 'Poco::Net::SocketAcceptor' c:\Documents and Settings\patrick\My Documents\VirtualWorld\Cave\src\ReactorServer.cpp 125
What does line 125 (and possibly the few preceding it) of ReactorServer.cpp look like?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Sorry, I should have posted that with my original code. I assume you're referring to the first example. This was the call to the mutator acceptor.setCommSystem(commSystem); . The previous lines of code are initializations for other classes that are irrelevant to this problem with the exception of the call to the constructor just prior to this. That was SocketAcceptor<reactorservicehandler> acceptor(svs, reactor);</reactorservicehandler>
Here's a little summary of the files so that this all makes more sense. ReactorServer is the class that is trying to declare a ReactorServiceHandler which uses the <servicehandler> template. CommunicationSystem* comms (or commSystem, depending on where you read it in the post) is just a pointer to an object that manages these objects (among others) that deal with communications. (It's similar to the Facade design pattern).
|
|
|
|
|
Have you considered trying to reproduce this scenario with a much simpler set of classes? As it is, there's way too much code here, both shown and not, to wade through and have any chance of understanding it.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I create a List ctrl derivered from CListCtrl. In this class, I implement item changed event
class CMyListCtrl :
public CListCtrl
....
BEGIN_MESSAGE_MAP(CMyListCtrl, CListCtrl)
ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, &CTrendListCtrl::OnLvnItemchanged)
END_MESSAGE_MAP()
......
void CMyListCtrl::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)
{
..
}
Then, on my dialog, there's a CMyListCtrl object, like this
CMyListCtrl m_lst;
afx_msg void OnLvnItemchangedList(NMHDR *pNMHDR, LRESULT *pResult);
I try to implement the item changed on that list.
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_GROUP, &CMyDlg::OnLvnItemchangedList)
END_MESSAGE_MAP()
void CMyDlg::OnLvnItemchangedList(NMHDR *pNMHDR, LRESULT *pResult)
{
...
}
The problem is, if I implement (1), then it doesn't run (2). And if I doesn't implement (1), it can run (2).
Actually I want to run both (1) and (2).
What should I do in this case?
Thank you very much, bro.
|
|
|
|
|
Try changing ON_NOTIFY_REFLECT to ON_NOTIFY_REFLECT_EX and return TRUE inside your CMyListCtrl::OnLvnItemchanged handler.
Best Wishes,
-David Delaune
|
|
|
|
|
uhm, I'm not sure that ...
Is this what you mean:
ON_NOTIFY_REFLECT_EX(LVN_ITEMCHANGED, &CMyListCtrl::OnLvnItemchanged)
BOOL CMyListCtrl::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<lpnmlistview>(pNMHDR);
*pResult = 0;
....
return TRUE;
}
</lpnmlistview>
I cannot see any change .....
|
|
|
|
|
|
uhm, I already tried return FALSE, but it's not better.
.. I will try this a litter bit later.
Thank you very much, David Delaune.
|
|
|
|
|
does any one have any idea in this case???
help me, please!!!
|
|
|
|
|
maybe the best way is avoid it. It's terrible the way MFC handle an event,
anyway, thank you very much, Randor!!
|
|
|
|
|
how do i know the number of messages left unprocessed in a message queue?
|
|
|
|
|
This depends on the implementation of the message queue. If you have a message queue class, perhaps there is a getQueueLength() method? Or, if it's implemented similarly to a C string, perhaps there is a terminator at the end of an array? There is always a brute force approach, iterate through every element and count it, but this is not what I would call a good solution.
On that note, to give you a good answer, you need to post more information about what you're doing.
|
|
|
|
|
I am just reusing the message queue provided by windows. I have a message handler thread which at some point need to flush out the message queue. I didnt seem to find any win apis for the same.
|
|
|
|
|
I must admit, I havn't used the Microsoft queue, but I have used my own queues as well as queues written for POSIX in Linux. Typically, I've found that there is a length() method on the queue class. In the searches that I just ran I can't say that I've found this to be the case for Microsoft, but I did notice a few methods that could be used to cobble something up with from here: http://msdn.microsoft.com/en-us/library/ms699810(VS.85).aspx[^].
A few ideas that came to mind as I was reading this (unfortunately none of them are as elegant as a getLength() method). One idea that could work is to EnableNotification() and then to have your own counter that increments when a message is received and decrements when a message is used. Another is to use repeated calls to the PeekNext() method in a loop, counting the number of elements in the queue as you go.
Sorry I couldn't be more insightful for you. I hope that what I've found helps you set up an algorithm to get your program working the way you want it to.
|
|
|
|
|
Why would you think that Windows would need help in managing its message queue?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
namaskaaram wrote: I have a message handler thread which at some point need to flush out the message queue.
Call PeekMessage(...PM_REMOVE) in a loop until it returns 0.
But really, why? Where are the messages coming from and why
do you have no control over this?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Suppose the path comes as C:\Program Files\n1\n2,the code i am mentioning below only deletes the contents of n2 and n2.what modification should i do to delete n1 also.please reply immeaditely,as my project deadline is appraoching near.if posible reply to my e-mailid abhinay.krs@gmail.com
BOOL CMbaloadApp::DeletePath (CString& path)
{
HANDLE hFile = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA fd;
CString buffer;
BOOL bContinue = TRUE;
// Build enumeration of path contents
buffer = path;
NameAppendFile (buffer, "*.*");
// Init buffes
memset (&fd, 0, sizeof(fd));
// Perform find first...
hFile = FindFirstFile (buffer, &fd);
if (hFile != INVALID_HANDLE_VALUE)
{
do
{
// Check for directory attribute on
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
// Directory Found!
// Make sure we don't have "." or ".."
if ( strcmp (fd.cFileName, ".") &&
strcmp (fd.cFileName, "..") )
{
// We have a valid directory, build path to it and
// call self to remove all
buffer = path;
NameAppendFile (buffer, fd.cFileName);
bContinue = DeletePath (buffer);
}
}
else
{
// Remove this file
buffer = path;
NameAppendFile (buffer, fd.cFileName);
// Normalize the file attributes prior to deleting it
SetFileAttributes(buffer, FILE_ATTRIBUTE_NORMAL);
TRY
{
// Get rid of it...
CFile::Remove (buffer);
}
CATCH( CFileException, e )
{
// Flag it, we can't remove directory
bContinue = FALSE;
DumpDebug ("Failed to delete file %s", buffer, 1);
}
END_CATCH
}
// Find the next entry...
} while (FindNextFile (hFile, &fd));
// Release file handle info
FindClose (hFile);
}
// Remove actual path itself
if (bContinue)
{
bContinue = (_rmdir(path) == 0);
}
return bContinue;
}
|
|
|
|
|
Abhinay Kumar wrote: what modification should i do to delete n1 also.
Recursion is one way. Another way is to use SHFileOperation() .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi david.thanks for such a prompt reply.but Can u tell me how should i modify my code n where in case of recursion to delete n1?Or how and where
should i be using the other alternative u mentioned.if u can please reply
it's very imp. for me.thanks.
|
|
|
|
|
Abhinay Kumar wrote: should i be using the other alternative u mentioned.
You can, but that's ultimately up to you.
SHFILEOPSTRUCT shfo = {0};
shfo.wFunc = FO_DELETE;
shfo.pFrom = "C:\\Program Files\\n1\\*.*\0";
shfo.pTo = "\0";
SHFileOperation(&shfo);
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi david i used the following recursive approach but it doesnot deletes
n1 in c:\program files\n1\n2.only deletes n2 and its contents.
if possible plz tell me what modification should i do to delete in n1 in this code or any other code to recursion.
BOOL CMbaloadApp::DeletePath (CString& path)
{
HANDLE hFile = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA fd;
CString buffer;
BOOL bContinue = TRUE;
// Build enumeration of path contents
buffer = path;
NameAppendFile (buffer, "*.*");
// Init buffes
memset (&fd, 0, sizeof(fd));
// Perform find first...
hFile = FindFirstFile (buffer, &fd);
if (hFile != INVALID_HANDLE_VALUE)
{
do
{
// Check for directory attribute on
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
// Directory Found!
// Make sure we don't have "." or ".."
if ( strcmp (fd.cFileName, ".") &&
strcmp (fd.cFileName, "..") )
{
// We have a valid directory, build path to it and
// call self to remove all
buffer = path;
NameAppendFile (buffer, fd.cFileName);
bContinue = DeletePath (buffer);
}
}
else
{
// Remove this file
buffer = path;
NameAppendFile (buffer, fd.cFileName);
// Normalize the file attributes prior to deleting it
SetFileAttributes(buffer, FILE_ATTRIBUTE_NORMAL);
TRY
{
// Get rid of it...
CFile::Remove (buffer);
}
CATCH( CFileException, e )
{
// Flag it, we can't remove directory
bContinue = FALSE;
DumpDebug ("Failed to delete file %s", buffer, 1);
}
END_CATCH
}
// Find the next entry...
} while (FindNextFile (hFile, &fd));
// Release file handle info
FindClose (hFile);
}
// Remove actual path itself
if (bContinue)
{
bContinue = (_rmdir(path) == 0);
}
return bContinue;
}
|
|
|
|
|
Abhinay Kumar wrote: HANDLE hFile = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA fd;
Do you not like MFC's CFileFind class? Your code is much longer than it needs to be as a result.
Abhinay Kumar wrote: NameAppendFile (buffer, "*.*");
Why are you using this function when CString has its own concatenation method?
That said, have you stepped through this code using the debugger? You'll hopefully notice that the path parameter does not contain a valid path when called recursively (hint: it's missing a backslash).
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|