Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Noob question, component version. (Read 3202 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Noob question, component version.

Hi, sorry for such a noob question but I'm just starting with the foobar2000 sdk and I'm having trouble finding all the info I need and understanding fully how it works,

Now I just want to print in the console the version of my component.

I'm sure it's a trivial thing but, anyone can help me?

Thanks.

Noob question, component version.

Reply #1
File/Preferences (or Ctrl+P) -> Components -> button: Copy report. It won't print anything in the console, but it will copy to clipboard info about ALL your components.You canalso doubleclick on every component and it will display small window with basic info.

Noob question, component version.

Reply #2
He's asking how he should do it with a function for his own component, not get info from others. This is the development section.
Windows 10 Pro x64 // foobar2000 1.3.10


Noob question, component version.

Reply #4
See console::formatter class, DECLARE_COMPONENT_VERSION macro and initquit service. The last one is only included as an example to trigger the message. I would generally not recommend for a component to spam its version to the console on start-up, mainly because it would be redundant information.

Code: [Select]
#define NAME "My component"
#define VERSION "v1.337"
DECLARE_COMPONENT_VERSION(NAME,VERSION,"Description goes here.")

class my_initquit : public initquit {
public:
  virtual void on_init() {
    console::formatter() << NAME << " " << VERSION;
  }
  virtual void on_quit() {
  }
}
static initquit_factory<my_initquit> my_initquit_factory;

Noob question, component version.

Reply #5
See console::formatter class, DECLARE_COMPONENT_VERSION macro and initquit service. The last one is only included as an example to trigger the message. I would generally not recommend for a component to spam its version to the console on start-up, mainly because it would be redundant information.

Code: [Select]
#define NAME "My component"
#define VERSION "v1.337"
DECLARE_COMPONENT_VERSION(NAME,VERSION,"Description goes here.")

class my_initquit : public initquit {
public:
  virtual void on_init() {
    console::formatter() << NAME << " " << VERSION;
  }
  virtual void on_quit() {
  }
}
static initquit_factory<my_initquit> my_initquit_factory;


Thanks for the tip foosion. I actually didn't wanted to actually print the version in the console, just a quick test to see how to get the component version.

I was trying to get the component version using the sdk, but I hadn't thought of using a constant.. 

Noob question, component version.

Reply #6
I was trying to get the component version using the sdk
That would be quite cumbersome. The DECLARE_COMPONENT_VERSION macro defines a componentversion factory in an anonymous namespace, so you cannot reference it from other code directly. You could explicitly defines a suitable factory, but this still is not as straightforward as using a constant.

Noob question, component version.

Reply #7
I was trying to get the component version using the sdk
That would be quite cumbersome. The DECLARE_COMPONENT_VERSION macro defines a componentversion factory in an anonymous namespace, so you cannot reference it from other code directly. You could explicitly defines a suitable factory, but this still is not as straightforward as using a constant.


Thanks again