Thread: Pluggable C++ Code

  1. #16
    Registered User
    Join Date
    Aug 2009
    Posts
    198
    Quote Originally Posted by Dae View Post
    Using scripting languages for GUI implementation is fairly common. Another common method is just using XML (create, configuration, events, etc). Smaller projects just use the GUI API directly (ala C++).
    I'm still not sure that you get it. The pluggable part is NOT a layout diagram for an existing toolkit.

    It is a component of an experimental GUI toolkit that I am making that draws the contents of the controls on the raw window at the command of the main code. Simply swapping out this part you can change how the controls of all programs that use it look.

    Quote Originally Posted by Dae View Post
    Compiling them separately would certainly work for themes, like plugins, but seems impractical imo.
    The user that wants to change the theme does not have to compile it. The person that created the theme has to compile it to a .so file or whatever it should be, and the user can just swap those out.

    I am still not sure how you can change the theme while the program is running, because it would be quite annoying to have to exit all your programs to change the theme.

    I wonder how toolkits like GTK+ and Qt do it.

    GTK+ uses some kind of separate theme engines and a special language, it doesn't seem like a fast, elegant, and versatile solution to me.

    I heard that Qt themes actually are written in C++ code, not sure how it actually works.
    Last edited by MTK; 11-29-2009 at 07:22 AM.

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    So long as you do not actually load the library into memory, you can swap them all out however you want.
    So if you want the user to change a theme, you could, say, enumerate the directory of plugins, load them, call a function inside them to get a friendly name or something. And when the user selects a new theme, you simply unload the old library and load the new library.
    Hot pluggable.

    This should work with the API you have been given.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #18
    Registered User
    Join Date
    Aug 2009
    Posts
    198
    Quote Originally Posted by Elysia View Post
    So long as you do not actually load the library into memory
    Won't it be very, very slow then?

  4. #19
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Not at all...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #20
    Registered User
    Join Date
    Aug 2009
    Posts
    198
    is that just because hard drives have a cache?

  6. #21
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    If you load the libraries once and only unload them when changing a theme, it should not be slow.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #22
    Registered User
    Join Date
    Aug 2009
    Posts
    198
    How would tha program know that the theme is being changed?

  8. #23
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Usually, you would have the user notify the program to change theme, no?
    A command option or a gui option?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #24
    Registered User
    Join Date
    Aug 2009
    Posts
    198
    This was going to be more of a library used by many applications.

  10. #25
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    But, I mean, you know when to swap the library, do you not? In some way, you would know. And when knowing, you can load/unload only when necessary.
    Loading and unloading all the time will be expensive, naturally, so you just have to limit it down somehow. This is the only way that you can hot plug code.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #26
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by MTK View Post
    I'm still not sure that you get it. The pluggable part is NOT a layout diagram for an existing toolkit.

    It is a component of an experimental GUI toolkit that I am making that draws the contents of the controls on the raw window at the command of the main code. Simply swapping out this part you can change how the controls of all programs that use it look.

    The user that wants to change the theme does not have to compile it. The person that created the theme has to compile it to a .so file or whatever it should be, and the user can just swap those out.
    I get it. o.0 I use, and create, a lot of applications that do this. It's dynamic, and you do it on Windows with .DLL's and on Linux with .SO's. Console emulators use it to load plugins, .DLL's, compiled by other developers. Valve HL2 engine uses it to load client/server, .DLL's, compiled by game developers. You could use it to load themes, .SO's, created by other developers, I just meant it seems overkill.

    Anyway, looks like you got your answer, a long time ago, specifics in brewbuck's post.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM