LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-25-2005, 02:18 AM   #1
chanwing
Member
 
Registered: Feb 2005
Posts: 42

Rep: Reputation: 15
Question Registry and Thread problem for C++




I am a newbie about linux programming.
I have only little idea about Registry and thread.
I have some questions about Registry and thread.
I have a program which is written by VC++6.0
It include some registry and threads.
I am using the RedHat9.2 and Kdevelop/Qt is my programming development tool.

My questions are as follows:
are they similar to Linux?
How can I write a program with registry and thread?
how can I get more information about registry and thread for my reference?
are there any reference books that includes all of the information?

Can anyone help me?
I would be grateful if you can answer my questions
Thanks
 
Old 03-25-2005, 02:21 AM   #2
chanwing
Member
 
Registered: Feb 2005
Posts: 42

Original Poster
Rep: Reputation: 15
sorry I forgot to tell you that I need to convert the window program into linux program
 
Old 03-25-2005, 08:27 AM   #3
BoldKiller
Member
 
Registered: Apr 2002
Location: Montreal, Quebec
Distribution: Debian, Gentoo, RedHat
Posts: 142

Rep: Reputation: 15
Wow, big question!! Lets proceed by order

1- Thread
Linux (and any posix system) uses pthread. The concept is really similar to win32 threads, but the API and parameters are differents. If you port your application to pthread, you can actually use pthread in windows with the pthread-win32-librairy. (http://sources.redhat.com/pthreads-win32/). You can also check pthread man page.

2- Registry
There is no such thing in linux. You would need to write an interface that opens a config file and reads values. I would do it in the form "key "value" #comment". Dependaing how the original application is written, it can be easy or really hard. For exemple, if all registry call are in a single class, just replace that class, if they are scatered all over, then "find in files" will become your best friend!!! For reference on the win32 registry, see the microsoft web site (developper section -- msdn).

As for the porting issue, I hope you know what you are getting in. There will be all sort of problems and you will need to really undestand the application and the code. I dont want to discourage you. Just want to make sure you realize porting is not an easy task, espeacily if the application was not written with porting in mind!

Good luck
 
Old 03-27-2005, 06:39 AM   #4
chanwing
Member
 
Registered: Feb 2005
Posts: 42

Original Poster
Rep: Reputation: 15
Thank you very much "BoldKiller"

Thread and Registry are really new for me.
You provide me very useful information.
Really thx for your kind and nice help.



 
Old 03-29-2005, 07:17 PM   #5
chanwing
Member
 
Registered: Feb 2005
Posts: 42

Original Poster
Rep: Reputation: 15

Sorry, I have a foolish question again.
In registry problem, what kinds of config file that I can read and where can I find them in Linux?
 
Old 03-29-2005, 07:26 PM   #6
BoldKiller
Member
 
Registered: Apr 2002
Location: Montreal, Quebec
Distribution: Debian, Gentoo, RedHat
Posts: 142

Rep: Reputation: 15
Usally configs are found in /etc. You could also put your config files in the same folders as your application. Your choise.

As for reading those config, you could write some code to parse the file and read. If the config are really simple, it could be the way to go. For more complex things, you can use the libraiy of awk (or gawk under Linux).

You could also check out gnu flex. I have never used that one. But it can parse text and find expression. It might be a little too powerfull (and complex) for your needs.

As for the format of the file, I would use something that is similar to the registry. A key, value pair.

Code:
key1 value1
key2 value2
StartApp 1
You might also need a type field:
Code:
key1 type1 value1
key2 type2 value2
StartApp bool 1

Hope this helps!!
 
Old 03-29-2005, 07:56 PM   #7
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
gnome provides an api similar to the windows registry; I imagine KDE provides one too. I've looked into the gnome one a little -- it's fairly straight forward and yes, your app will still work in a non-gnome desktop, even KDE, as long as the proper gnome shared libraries are installed. That'd be true for the KDE api if there is one, as well.
 
Old 03-29-2005, 08:32 PM   #8
chanwing
Member
 
Registered: Feb 2005
Posts: 42

Original Poster
Rep: Reputation: 15

Thank you BoldKiller and aluser..
I think I need time to understand those things.
Really thanks for your immediately reply and help.
 
Old 04-02-2005, 04:33 PM   #9
adymo
LQ Newbie
 
Registered: Jan 2005
Posts: 9

Rep: Reputation: 0
Search for Blanchette book on Qt3 (available online iirc). There you will find info about threads (QThread class).
As for registry, use QSettings or KConfig classes. They are quite similar and will give you an access to the ini-like configuration db.
 
Old 04-05-2005, 12:17 AM   #10
chanwing
Member
 
Registered: Feb 2005
Posts: 42

Original Poster
Rep: Reputation: 15

Thank you adymo.
I saw the book "Blanchette book on Qt3 " of the "Using Qt's Classes in Non-GUI Threads" but it is just a few pages about the Non-GUI threads .
In fact, my program ( the window version) has GUI threads and non-GUI threads. Also, it has a file that is mainly handle the non-GUI threads.
Can I use the Qt to handle the GUI thread and non-GUI thread OR I use the pthread for non-GUI thread and Qt for GUI thread? which one is better?
 
Old 04-21-2005, 02:54 AM   #11
chanwing
Member
 
Registered: Feb 2005
Posts: 42

Original Poster
Rep: Reputation: 15



In fact, I have a file that mainly handle the thread. However, I don't know how to convert the following codes into Linux.
For me, I don't want to change the structure of this file because if I change it, I need to change all the other files correspondingly. Do anyone know how to migrate them into Linux? or can anyone give me some suggestions / advices that how I can do?
Thank you very much

The codes are as follows:

in ".h" file

CMap<DWORD,DWORD,CSingleLockCount*,CSingleLockCount*>sLockMap;

CTypedPtrArray<CPtrArray, Task*>TaskArray;

CTypedPtrList<CPtrList, Taskcommand*>CommandList;

in ".cpp"file

sLockMap.RemoveALL();
sLockMap.RemoveKey(id);
sLockMap.SetAt();

CommandList.RemoveHead();

etc.....

Sorry that I can't paste the whole coding there because it is so huge.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Gnome 2.8 - containing a registry? scuzzman General 2 11-08-2004 09:57 PM
Main thread sending notification to child thread rajesh_b Programming 1 09-22-2004 09:15 AM
wine registry problem Rydog2987 Linux - Software 3 08-13-2004 09:50 PM
configure qt thread issue (just compiled qt w/ -thread option) cleff Linux - Software 8 05-07-2004 11:11 PM
New Thread problem jeremy LQ Suggestions & Feedback 0 04-03-2002 08:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration