187ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk/* 287ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk* Copyright 2006 Sony Computer Entertainment Inc. 387ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk* 487ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk* Licensed under the MIT Open Source License, for details please see license.txt or the website 587ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk* http://www.opensource.org/licenses/mit-license.php 687ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk* 787ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk*/ 887ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 987ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk#ifndef __DAE_IOPLUGIN__ 1087ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk#define __DAE_IOPLUGIN__ 1187ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 1287ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk#include <string> 1387ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk#include <vector> 1487ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk#include <dae/daeTypes.h> 1587ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchoukclass daeDatabase; 1687ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchoukclass daeMetaElement; 1787ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchoukclass daeURI; 1887ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchoukclass daeDocument; 1987ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 2087ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk/** 2187ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk* The @c daeIOPlugin class provides the input/output plugin interface, which is 2287ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk* the interface between the COLLADA runtime and the backend storage. A native 2387ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk* COLLADA XML plugin implementation is provided along with this interface. 2487ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk*/ 2587ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchoukclass DLLSPEC daeIOPlugin 2687ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk{ 2787ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchoukpublic: 2887ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk /** 2987ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * Destructor 3087ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk */ 3187ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual ~daeIOPlugin() {} 3287ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk /** 3387ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * Sets the top meta object. 3487ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * Called by @c dae::setIOPlugin() when the IO plugin changes. It passes to this function the 3587ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * top meta object, which is the root of a 3687ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * hierarchy of @c daeMetaElement objects. This top meta object is capable of creating 3787ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * any of the root objects in the DOM tree. 3887ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @param topMeta Top meta object to use to create objects to fill the database. 3987ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @return Returns DAE_OK if successful, otherwise returns a negative value defined in daeError.h. 4087ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk */ 4187ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual daeInt setMeta(daeMetaElement *topMeta) = 0; 4287ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 4387ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk /** @name Database setup */ 4487ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk //@{ 4587ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk /** 4687ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * Sets the database to use. 4787ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * All @c daeIOPlugins use the same interface to the @c daeDatabase, 4887ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @c setDatabase() tells the @c daeIOPlugin which @c daeDatabase object it should use 4987ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * for storage and queries. 5087ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @param database Database to set. 5187ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk */ 5287ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual void setDatabase(daeDatabase* database) = 0; 5387ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk //@} 5487ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 5587ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 5687ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk /** @name Operations */ 5787ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk //@{ 5887ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk /** 5987ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * Imports content into the database from an input. 6087ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * The input can be a file, a database or another runtime. 6187ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @param uri the URI of the COLLADA document to load, not all plugins accept all types of URIs, 6287ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * check the documentation for the IO plugin you are using. 6387ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @param docBuffer A string containing the text of the document to load. This is an optional attribute 6487ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * and should only be used if the document has already been loaded into memory. 6587ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @return Returns DAE_OK if successfully loaded, otherwise returns a negative value defined in daeError.h. 6687ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @see @c DAE::load(). 6787ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk */ 6887ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual daeInt read(const daeURI& uri, daeString docBuffer) = 0; 6987ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 7087ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk /** @name Operations */ 7187ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk //@{ 7287ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk /** 7387ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * Writes a specific document to an output. 7487ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @param name URI to write the document to, not all IO plugins support all types of URIs 7587ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * check the documentation for the IO plugin you are using. 7687ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @param document Pointer to the document that we're going to write out. 7787ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @param replace True if write should overwrite an existing file. False otherwise. 7887ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @return Returns DAE_OK if success, a negative value defined in daeError.h otherwise. 7987ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @see @c DAE::saveAs() 8087ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk */ 8187ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual daeInt write(const daeURI& name, daeDocument *document, daeBool replace) = 0; 8287ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk //@} 8387ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 8487ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk /** 8587ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * Returns a list of the URI protocols that this plugin supports. 8687ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @return Returns a daeArray containing the supported protocols. 8787ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk */ 8887ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual const std::vector<std::string>& getSupportedProtocols() { 8987ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk return supportedProtocols; 9087ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk } 9187ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 9287ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk /** 9387ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * setOption allows you to set options for this IOPlugin. Which options a plugin supports is 9487ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * dependent on the plugin itself. There is currently no list of options that plugins are 9587ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * suggested to implement. 9687ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @param option The option to set. 9787ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @param value The value to set the option. 9887ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @return Returns DAE_OK upon success. 9987ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk */ 10087ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual daeInt setOption( daeString option, daeString value ) = 0; 10187ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 10287ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk /** 10387ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * getOption retrieves the value of an option from this IOPlugin. Which options a plugin supports is 10487ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * dependent on the plugin itself. 10587ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @param option The option to get. 10687ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk * @return Returns the string value of the option or NULL if option is not valid. 10787ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk */ 10887ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual daeString getOption( daeString option ) = 0; 10987ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 11087ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchoukprotected: 11187ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk // This is an array of the URI protocols supported by this plugin, e.g. "http", "file", 11287ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk // etc. Each plugin should initialize this variable in the constructor. 11387ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk std::vector<std::string> supportedProtocols; 11487ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk}; 11587ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 11687ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 11787ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchoukclass DLLSPEC daeIOEmpty : public daeIOPlugin { 11887ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchoukpublic: 11987ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual daeInt setMeta(daeMetaElement *topMeta) { return DAE_ERROR; } 12087ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual void setDatabase(daeDatabase* database) { } 12187ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual daeInt read(const daeURI& uri, daeString docBuffer) { return DAE_ERROR; } 12287ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual daeInt write(const daeURI& name, daeDocument *document, daeBool replace) { return DAE_ERROR; } 12387ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual daeInt setOption( daeString option, daeString value ) { return DAE_ERROR; } 12487ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk virtual daeString getOption( daeString option ) { return ""; } 12587ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk}; 12687ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 12787ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk 12887ac3e2db6d5ae163131102c066e9d19bdfdc139Alex Sakhartchouk#endif // __DAE_IOPLUGIN__ 129