foobar2000 SDK  2015-08-03
componentversion.h
Go to the documentation of this file.
1 class NOVTABLE componentversion : public service_base {
3 public:
4  virtual void get_file_name(pfc::string_base & out)=0;
5  virtual void get_component_name(pfc::string_base & out)=0;
6  virtual void get_component_version(pfc::string_base & out)=0;
7  virtual void get_about_message(pfc::string_base & out)=0;//about message uses "\n" for line separators
8 
9  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(componentversion);
10 };
11 
14  const char * name,*version,*about;
15 public:
16  //do not derive/override
18  virtual void get_component_name(pfc::string_base & out) {out.set_string(name?name:"");}
19  virtual void get_component_version(pfc::string_base & out) {out.set_string(version?version:"");}
20  virtual void get_about_message(pfc::string_base & out) {out.set_string(about?about:"");}
21  explicit componentversion_impl_simple(const char * p_name,const char * p_version,const char * p_about) : name(p_name), version(p_version), about(p_about ? p_about : "") {}
22 };
23 
26  pfc::string8 name,version,about;
27 public:
28  //do not derive/override
30  virtual void get_component_name(pfc::string_base & out) {out.set_string(name);}
31  virtual void get_component_version(pfc::string_base & out) {out.set_string(version);}
32  virtual void get_about_message(pfc::string_base & out) {out.set_string(about);}
33  explicit componentversion_impl_copy(const char * p_name,const char * p_version,const char * p_about) : name(p_name), version(p_version), about(p_about ? p_about : "") {}
34 };
35 
38 
40 public:
41  componentversion_impl_simple_factory(const char * p_name,const char * p_version,const char * p_about) : __componentversion_impl_simple_factory(p_name,p_version,p_about) {}
42 };
43 
45 public:
46  componentversion_impl_copy_factory(const char * p_name,const char * p_version,const char * p_about) : __componentversion_impl_copy_factory(p_name,p_version,p_about) {}
47 };
48 
55 #define DECLARE_COMPONENT_VERSION(NAME,VERSION,ABOUT) \
56  namespace {class componentversion_myimpl : public componentversion { public: componentversion_myimpl() {PFC_ASSERT( ABOUT );} \
57  void get_file_name(pfc::string_base & out) {out = core_api::get_my_file_name();} \
58  void get_component_name(pfc::string_base & out) {out = NAME;} \
59  void get_component_version(pfc::string_base & out) {out = VERSION;} \
60  void get_about_message(pfc::string_base & out) {out = ABOUT;} \
61  }; static service_factory_single_t<componentversion_myimpl> g_componentversion_myimpl_factory; }
62  // static componentversion_impl_simple_factory g_componentversion_service(NAME,VERSION,ABOUT);
63 
65 #define DECLARE_COMPONENT_VERSION_COPY(NAME,VERSION,ABOUT) \
66  static componentversion_impl_copy_factory g_componentversion_service(NAME,VERSION,ABOUT);
67 
68 
72 public:
73  virtual bool is_installed_correctly() = 0;
74 
75  static bool test_my_name(const char * fn);
76  static bool have_other_file(const char * fn);
77 
78  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(component_installation_validator)
79 };
80 
83 public:
84  component_installation_validator_filename(const char * dllName) : m_dllName(dllName) {}
86  return test_my_name(m_dllName);
87  }
88 private:
89  const char * const m_dllName;
90 };
91 
92 #define VALIDATE_COMPONENT_FILENAME(FN) \
93  static service_factory_single_t<component_installation_validator_filename> g_component_installation_validator_filename(FN);
virtual void get_file_name(pfc::string_base &out)
componentversion_impl_simple_factory(const char *p_name, const char *p_version, const char *p_about)
virtual void get_component_version(pfc::string_base &out)
component_installation_validator_filename(const char *dllName)
Implementation helper. You typically want to use DECLARE_COMPONENT_VERSION() instead.
componentversion_impl_copy(const char *p_name, const char *p_version, const char *p_about)
virtual void get_about_message(pfc::string_base &out)
service_factory_single_transparent_t< componentversion_impl_copy > __componentversion_impl_copy_factory
componentversion_impl_simple(const char *p_name, const char *p_version, const char *p_about)
Entrypoint interface for declaring component&#39;s version information. Instead of implementing this dire...
service_factory_single_transparent_t< componentversion_impl_simple > __componentversion_impl_simple_factory
virtual void get_component_name(pfc::string_base &out)
const char * get_my_file_name()
Retrieves filename of calling dll, excluding extension, e.g. "foo_asdf".
Implementation helper. You typically want to use DECLARE_COMPONENT_VERSION() instead.
Simple implementation of component_installation_validator that makes sure that our component DLL has ...
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Definition: service.h:333
virtual void get_component_version(pfc::string_base &out)
virtual void set_string(const char *p_string, t_size p_length=~0)
Definition: string_base.h:198
virtual void get_about_message(pfc::string_base &out)
virtual void get_file_name(pfc::string_base &out)
componentversion_impl_copy_factory(const char *p_name, const char *p_version, const char *p_about)
virtual void get_component_name(pfc::string_base &out)