PDA

View Full Version : Read File -> Use class



T0bi4s
7th February 2010, 12:18
Hi,

today I got a pretty tough question, or at least I think it's a tough one:).

Is it possible check the files in the project and somehow read those files, but not characters or whatever. I want to use to class which is created in this file. So if there is a file, I'll be able to use this class in this project, if not, then not. I know how to implement that in assembler, so i thought maybe it's possible to do that in QT too.

I hope someone can make a rime out of what I'm saying and tell me wheter that's possible or not, and if so, how to do it.

Thanks
Tobias

squidge
7th February 2010, 12:29
You want to use class in a file if the file is there, but not to use the class in the file if the file is not there? You want to use this at runtime rather than before the compilation and link steps.

In which case, I would refer you to the Component Object Model (http://en.wikipedia.org/wiki/Component_Object_Model), which allows you to export a class from a file and access that class from another file at run time.

T0bi4s
7th February 2010, 13:03
Thanks for the quick reply.

Just read the article, sounds good, but how do I use it in QT, if I didn't get anything wrong I have to create special classes that suport this COM can i use those classes then without any trouble?
Do you know any whole code examples? That would be awesome to understand how it's implemented.

By the way, how do I use reflections in QT?

tobi

squidge
7th February 2010, 13:40
That depends on the target OS for your application, as well as the data you wish to exchange with this other class. If the target app is Linux, or other Unix-like OS, then DBus may be preferred solution. Last I heard about DBus on Windows was that it was still in its infancy.

I'm not sure how you would use QObject-derived classes with COM (signals and slots across COM - I don't know if thats even possible), but data and methods should be easy enough.

Checkout the Introduction to COM (http://www.codeproject.com/KB/COM/comintro.aspx) and Introduction to RPC (http://www.codeproject.com/KB/IP/rpcintro1.aspx)

(Note that the introduction to COM doesn't describe how to write your own, but is a good introduction to see if it fits your requirements)