|
As a first step I would run the program under the debugger and try to find out where the error occurs. this should give some idea of the general problem area from where you can narrow it down to the more specific point of failure. Adding some debug trace code might also be useful.
|
|
|
|
|
Hi:
First thank you for your help.I want to give you my code, but i do not find where can add it,could you give me your e-mail address.think you.
|
|
|
|
|
Please see my previous message. You need to try and discover where the program is failing, and then examine the code in that area. Use the DEBUG mode and breakpoint facility to narrow the problem down. It is no good sending the complete code to me as I have no idea what the program is trying to do.
|
|
|
|
|
Hi all!!
I am loading a swf file inside the ActiveX object in my dialog, but some operations inside the swf are lenghy and make my dialog not responsive, is there a way to make the Activex object run in an another thread?
|
|
|
|
|
You could make the lengthy operation run in a separate thread within the activex control.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
(don't know if this should be in the design forum, anyway, I'm coding in C++)
I have a factory that will eventually create many, many different objects.
usually, I have something like (pseudo-c++-ish):
#include "type1Class.h"
#include "type2Class.h"
#include "type3Class.h"
#include "type4Class.h"
static BaseClass* MyClass::Builder(ObjectType type)
{
switch (type)
{
case type1: return new Type1Class;
case type2: return new Type2Class;
case type3: return new Type3Class;
case type4: return new Type4Class;
}
}
Now, for a small number of classes this is manageable; but for a large number of classes it creates a large number
of includes and a huge switch.
Is there another pattern or methodology to clean that potential mess ?
I known I can put all typeXClass.h includes in a separate include file and have that one included; that will reduce the number of lines; any other tips hints ?
Thanks.
--------- edit------
Thanks to Stuart and Cédric; I will have a look at their solution first thing after coffee next monday!
This signature was proudly tested on animals.
|
|
|
|
|
Maximilien wrote: Is there another pattern or methodology to clean that potential mess ?
I dont think so, but depends on your definition of large I guess - in which case you might want to partition your classes by some abstract case and have multiple factories.. you could also consider 'pre-allocating' the objects to trade off against the lookup time (if thats an issue) - we have an implementation in a realtime message-switch that only has 30-40 classes, one for each message, but we pre-allocate them in the factory before we start accepting connections
'g'
|
|
|
|
|
How would I do it...well, I'd make use of a std::map and some Boost magic:
struct BaseClass {};
struct C1 : public BaseClass {};
struct C2 : public BaseClass {};
struct C3 : public BaseClass {};
typedef BaseClass* BaseClassPtr;
BaseClassPtr Make(std::string const& type)
{
using namespace boost::lambda;
typedef boost::function<BaseClassPtr()> Constructor;
static const std::map<std::string, boost::function<BaseClassPtr()> > factoryMap =
boost::assign::map_list_of("C1", Constructor(new_ptr<C1>()))
("C2", Constructor(new_ptr<C2>()))
("C3", Constructor(new_ptr<C3>()));
const std::map<std::string, boost::function<BaseClassPtr()> >::const_iterator constructor = factoryMap.find(type);
return (constructor != factoryMap.end())?constructor->second():0;
}
Create a map that relates your factory key to a suitable object pointer constructor function object - here I've used Boost.Lambda's object construction functions.
When you look up a type key, you either find it (in which case you invoke the constructor) or not (in which case I return a null pointer).
Adding a new type only requires you to add one line to the map initialiser.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hooooo!!! sexy!
Thanks.
This signature was proudly tested on animals.
|
|
|
|
|
I use an approach similar to the one from Stuart's but by using some little tricks, you can automate the process of registration.
So, the base principle is that the factory is aa wrapper around a map with the class identifier (type) as key and a function to create the object as value. So, this way your factory remains independant of your different objects.
Then, you have a public function on your factory to add a new creation function to the map:
typedef BaseClass* CreateFunc ();
....
void RegisterCreator(ObjectType type, CreateFunc* pFunc);
Now the "smart" trick is to let the classes register themselves through static initialization. At the top of the cpp file of your class, you add code similar to this:
int RegisterType1Class()
{
CObjectFactory::GetInstance().RegisterCreator(Type1, Type1Class::CreateObject);
return 0;
}
static int Temp = RegisterType1Class();
The Type1Class::CreateObjec is a static function of your class which simply creates a new instance of the class.
This mechanism allows you to automatically register objects to your factory through static initialization. Your factory has to be a singleton also.
Using this technique, your factory remains completely independant from all your different specific objects (it only has to know the base class), and you get rid of the big ugly switch.
|
|
|
|
|
I know you already have answers...
But I'd look at this article, as I had a similar problem:
Enumerate your leaf classes[^]
This lets each class (inheriting froma common ancestor) register themselves, so it's all self contained. No adding a class in Pl;ace A, and not adding it to a list in place B.
Used it a few times myself.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
2 questions of rich edit control:
1. how to get last visible line - ref to function GetFirstVisibleLine(), or count of visible lines.
2. how to get line height of last line?
|
|
|
|
|
1. You could try using CharFromPos[^] specifying the bottom-left corner of the edit and LineFromChar[^] to get the line index of the character it returned, if any. Maybe it would work, maybeit would not...
2. No idea just yet, sorry...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
i need C code of Vernam Cipher Algorithm for my project work.plz help me .
|
|
|
|
|
In your reposts, you're loosing words...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
From what I can understand from a quick google, it looks like it's not a hard(*) thing to do.
-input XOR (randomly generated)mask = result.
-send result to receiver.
-result XOR mask = input.
-trash the mask.
(*) the difficulty would be to generate the random mask since generating truly random values is a very hard process.
What have you done already? did you do your homework and look at what this is ?
Did you try a few things ? do you have any workable code ?
This signature was proudly tested on animals.
|
|
|
|
|
I think he only wantz da codez.
|
|
|
|
|
I need C or C++ code of Vernam Cipher Algorithm for my project work.plz help me soon.
|
|
|
|
|
I need C or C++ code of Vernam Cipher Algorithm for my project work.plz help me soon.
|
|
|
|
|
My project compromises of a set of different process talking to each other. They communicate via file mapped shared memory. I ran into a problem when I was doing a symantec antivirus liveupdate when the different processes of our application starts behaving erratically.
I had to reboot to recover and then excluded the directory of my application and the shared page file from antivirus scanning.
Now all the processes of my application for some strange reason began crashing everyday midnight while accessing the shared memory. I managed to find that when some of these processes were configured to not use the shared memory, those processes didnt terminate.
Can anyone shed light on why this could be happening - esp why application went for a toss during the liveupdate. Is there any way/tools to debug crashes in the file mapped shared memory files??
Appreciate your help.
|
|
|
|
|
Hi avijaya,
Is this behavior only occuring on Windows XP? Also... did you supply a SECURITY_ATTRIBUTES Structure[^] when creating the mapping?
Best Wishes,
-David Delaune
|
|
|
|
|
Hi David,
I did provide SECURITY ATTRIBUTES when I did CreateFile and CreateFileMapping. I gave a security descriptor that allowed anyone to access the object.
This problem is seen on Windows 2k3 Server.
-avijaya.
|
|
|
|
|
Friends,
void CAfxDumpStackDlg::Test()
{
AfxDumpStack( AFX_STACK_DUMP_TARGET_ODS );
}
AfxDumpStack API call in the above code block dumps only the following information.
"=== begin AfxDumpStack output ===
Loaded 'C:\WINDOWS\system32\dbghelp.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information found.
7C90EB94: WINDOWS\system32\ntdll.dll! KiFastSystemCallRet
59A830F0: WINDOWS\system32\DBGHELP.dll! DbgHelpCreateUserDump + 331 bytes
=== end AfxDumpStack() output ==="
What should I do more to get the detailed dump?
Thanks in advance,
Krishnakumar
|
|
|
|
|
|