|
Hello,
I need to know about good C++ Reflection API(Would be better if Microsoft API is available) which enables me to determine the types(classes,structs,enums,ints,float,doubles...)identification at run time, declaring them and finally to call methods on those types at run time too.
Regards
Usman
|
|
|
|
|
Don't think that exists for C++.
see lengthy discussion on stackoverflow[^]
Watched code never compiles.
|
|
|
|
|
There isn't a good one - if you want to do Java style "create from arbitrary string" or "call method by string" then you won't be able to do it generally. If you're only interested in a subset of classes that you want to handle like that then have a look at the factory and abstract factory patterns, they might be enough for what you want, as might be COM (create an object by name, see if that object supports a particular interface) or CORBA.
Cheers,
Ash
|
|
|
|
|
Go managed.
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]
|
|
|
|
|
Sorry ,but C++ types runtime information is very limited.You could only get C++ clas instance type like this sample but calling a methods at runtime is not possible in general.
Life is a stage and we are all actors!
|
|
|
|
|
As other said before, this is not possible to do in C++. However, if you explain what exact situation you are trying to handle we might be able to suggest you an appropriate solution.
|
|
|
|
|
May be this is not what you want, but qt c++ framework do that.
|
|
|
|
|
Hi, is there any technics (owner draw class, function, subclass method and so on) to change backgroud color of datetimecontrol
Thank you
viliam
|
|
|
|
|
Check out the WM_CTLCOLOR , and related, messages.
If that does not work, you might look at the DTM_SETMCCOLOR message. Or, subclass the control and handle the WM_ERASEBKGND and WM_PAINT messages.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
WM_CONTROL is not called for this type of control
viliam
|
|
|
|
|
viliam wrote: WM_CONTROL is not called for this type of control
I've not ever heard of that message. Is it new?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Sorry, my typing error. I should be WM_CTLCOLOR
viliam
|
|
|
|
|
viliam wrote: Sorry, my typing error.
Don't "type" your code here. Please copy and paste!
Workout progress:
Current arm size: 14.4in
Desired arm size: 18in
Next Target: 15.4in by Dec 2010
Current training method: HIT
|
|
|
|
|
Hi,
Does anyone know how to load a map of maps? I've declared the map of maps as follows:
map<double,map<double,double>> a;
As a simple example, I'd like to load the following (in reality I'll be loading this format for nearly 500,000 entries):
0.0 1.57 2.65
0.5 0.00 3.21
1.0 6.52 0.00
1.5 0.17 4.54
The first column is the key (it is time in seconds).
Thanks,
|
|
|
|
|
you're using a map to store a matrix ?
Watched code never compiles.
|
|
|
|
|
|
For storing a matrix like this wouldn't a better representation be:
std::map< std::pair<unsigned, unsigned>, double > matrix;
and you can address the elements as:
matrix[ std::make_pair( 0, 0 ) ] = 0.5;
Cheers,
Ash
|
|
|
|
|
Use the Matrix[^] class from the Boost library.
|
|
|
|
|
Hi,
I took a look at boost, but it didn't seem to have methods for finding values in the matrix or deleting rows, etc.
|
|
|
|
|
It has begin() and end() methods that return iterators. Those can be used to find.
For deleting, it has an erase_element() method. Put that in a loop to delete an entire row.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi David,
So could I find, for example, a zero in a given column using this technique? How would you use .begin() and .end() to do this?
Thanks,
|
|
|
|
|
b-rad311 wrote: So could I find, for example, a zero in a given column using this technique?
At first glance, it appears not, however, I've never used it.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
How about something like:
struct entry
{
double key;
double val1;
double val2;
};
vector<entry> entries.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi David,
Thanks for replying. I'm trying to shy away from vector usage because, due to the large amount of data, vector storage and usage (particulary push_back) are killing the efficiency. So I'm trying to experiment with other methods such as map of maps.
|
|
|
|
|
Hi,
std::vector::push_back is only a problem if the internal storage for the vector has to change. If you do a std::vector::resrve to an estimate of the the maximum size of the vector before doing anything else it'll speed up push_back no end.
On a related point, lookup in a map of maps with loads of entries is going to be pretty slow...
Cheers,
Ash
|
|
|
|