1
0

svc_metadata.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include "foundation/foundation.h"
  3. #include "ifc_metadata.h"
  4. #include "ifc_metadata_editor.h"
  5. #include "nx/nxuri.h"
  6. // {7DBF780E-78B6-436C-A188-864AF6859D87}
  7. static const GUID metadata_service_type_guid =
  8. { 0x7dbf780e, 0x78b6, 0x436c, { 0xa1, 0x88, 0x86, 0x4a, 0xf6, 0x85, 0x9d, 0x87 } };
  9. class svc_metadata : public Wasabi2::Dispatchable
  10. {
  11. protected:
  12. svc_metadata() : Dispatchable(DISPATCHABLE_VERSION) {}
  13. ~svc_metadata() {}
  14. public:
  15. static GUID GetServiceType() { return metadata_service_type_guid; }
  16. // to make the implementation more flexible, you need to NXStringRelease on the extension you get (i.e. this function follows Apple's "Create" rule)
  17. int EnumerateExtensions(unsigned int index, nx_string_t *extension) { return MetadataService_EnumerateExtensions(index, extension); }
  18. int CreateMetadata(nx_uri_t filename, ifc_metadata **metadata) {return MetadataService_CreateMetadata(filename, metadata); }
  19. int CreateMetadataEditor(nx_uri_t filename, ifc_metadata_editor **metadata) { return MetadataService_CreateMetadataEditor(filename, metadata); }
  20. int DeserializeMetadata(nx_data_t data, ifc_metadata **metadata) { return MetadataService_DeserializeMetadata(data, metadata); }
  21. int CreateMetadata(unsigned int pass, nx_uri_t filename, ifc_metadata **metadata)
  22. {
  23. if (dispatchable_version == 0)
  24. {
  25. if (pass == 0)
  26. return MetadataService_CreateMetadata(filename, metadata);
  27. else
  28. return NErr_False;
  29. }
  30. else
  31. return MetadataService_CreateMetadata(pass, filename, metadata);
  32. }
  33. int CreateMetadataEditor(unsigned int pass, nx_uri_t filename, ifc_metadata_editor **metadata)
  34. {
  35. if (dispatchable_version == 0)
  36. {
  37. if (pass == 0)
  38. return MetadataService_CreateMetadataEditor(filename, metadata);
  39. else
  40. return NErr_False;
  41. }
  42. else
  43. return MetadataService_CreateMetadataEditor(pass, filename, metadata);
  44. }
  45. enum
  46. {
  47. DISPATCHABLE_VERSION=1,
  48. };
  49. private:
  50. // implementation note: to make the implementation more flexible, you need to NXStringRetain on the extension you pass back (i.e. follow Apple's "Create" rule)
  51. virtual int WASABICALL MetadataService_EnumerateExtensions(unsigned int index, nx_string_t *extension)=0;
  52. /* these two no longer have to be implemented */
  53. virtual int WASABICALL MetadataService_CreateMetadata(nx_uri_t filename, ifc_metadata **metadata) { return MetadataService_CreateMetadata(0, filename, metadata); }
  54. virtual int WASABICALL MetadataService_CreateMetadataEditor(nx_uri_t filename, ifc_metadata_editor **metadata) { return MetadataService_CreateMetadataEditor(0, filename, metadata); }
  55. virtual int WASABICALL MetadataService_DeserializeMetadata(nx_data_t data, ifc_metadata **metadata) { return NErr_NotImplemented; }
  56. virtual int WASABICALL MetadataService_CreateMetadata(unsigned int pass, nx_uri_t filename, ifc_metadata **metadata)=0;
  57. virtual int WASABICALL MetadataService_CreateMetadataEditor(unsigned int pass, nx_uri_t filename, ifc_metadata_editor **metadata)=0;
  58. };