Commit 0fb4954f authored by Dick Hollenbeck's avatar Dick Hollenbeck

fix comments, add IO_MGR::Save()

parent 086c8dec
...@@ -100,6 +100,25 @@ BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName, ...@@ -100,6 +100,25 @@ BOARD* IO_MGR::Load( PCB_FILE_T aFileType, const wxString& aFileName,
} }
void IO_MGR::Save( PCB_FILE_T aFileType, const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
{
// release the PLUGIN even if an exception is thrown.
PLUGIN::RELEASER pi = PluginFind( aFileType );
if( (PLUGIN*) pi ) // test pi->plugin
{
pi->Save( aFileName, aBoard, aProperties ); // virtual
return;
}
wxString msg;
msg.Printf( _( "Plugin type '%s' is not found." ), ShowType( aFileType ).GetData() );
THROW_IO_ERROR( msg );
}
BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties ) BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties )
{ {
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface, // not pure virtual so that plugins only have to implement subset of the PLUGIN interface,
...@@ -107,21 +126,21 @@ BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* ...@@ -107,21 +126,21 @@ BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES*
wxString msg; wxString msg;
msg.Printf( _( "Plugin %s does not implement the BOARD Load() function.\n" ), msg.Printf( _( "Plugin %s does not implement the BOARD Load() function." ),
PluginName().GetData() ); PluginName().GetData() );
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
} }
void PLUGIN::Save( const wxString* aFileName, BOARD* aBoard, PROPERTIES* aProperties ) void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
{ {
// not pure virtual so that plugins only have to implement subset of the PLUGIN interface, // not pure virtual so that plugins only have to implement subset of the PLUGIN interface,
// e.g. Load() or Save() but not both. // e.g. Load() or Save() but not both.
wxString msg; wxString msg;
msg.Printf( _( "Plugin %s does not implement the BOARD Save() function.\n" ), msg.Printf( _( "Plugin %s does not implement the BOARD Save() function." ),
PluginName().GetData() ); PluginName().GetData() );
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
......
...@@ -116,21 +116,27 @@ public: ...@@ -116,21 +116,27 @@ public:
/** /**
* Function Save * Function Save
* will write a full aBoard to a storage file in a format that this * will write either a full aBoard to a storage file in a format that this
* implementation knows about, or it can be used to write a portion of * implementation knows about, or it can be used to write a portion of
* aBoard to a special kind of export file. * aBoard to a special kind of export file.
* *
* @param aFileName is the name of a file to save to on disk. * @param aFileName is the name of a file to save to on disk.
* @param aBoard is the BOARD document (data tree) to save or export to disk. * @param aBoard is the BOARD document (data tree) to save or export to disk.
* *
* @param aBoard is the in memory document tree from which to extract information
* when writing to \a aFileName. The caller continues to own the BOARD, and
* the plugin should refrain from modifying the BOARD if possible.
*
* @param aProperties is an associative array that can be used to tell the * @param aProperties is an associative array that can be used to tell the
* saver how to save the file, because it can take any number of * saver how to save the file, because it can take any number of
* additional named tuning arguments that the plugin is known to support. * additional named tuning arguments that the plugin is known to support.
* The caller continues to own this object (plugin may not delete it), and
* plugins should expect it to be optionally NULL.
* *
* @throw IO_ERROR if there is a problem saving or exporting. * @throw IO_ERROR if there is a problem saving or exporting.
*/ */
static void Save( PCB_FILE_T aFileType, const wxString& aFileName, static void Save( PCB_FILE_T aFileType, const wxString& aFileName,
PROPERTIES* aProperties = NULL ); BOARD* aBoard, PROPERTIES* aProperties = NULL );
}; };
...@@ -237,7 +243,10 @@ public: ...@@ -237,7 +243,10 @@ public:
* aBoard to a special kind of export file. * aBoard to a special kind of export file.
* *
* @param aFileName is the name of a file to save to on disk. * @param aFileName is the name of a file to save to on disk.
* @param aBoard is the BOARD document (data tree) to save or export to disk. *
* @param aBoard is the class BOARD in memory document tree from which to
* extract information when writing to \a aFileName. The caller continues to
* own the BOARD, and the plugin should refrain from modifying the BOARD if possible.
* *
* @param aProperties is an associative array that can be used to tell the * @param aProperties is an associative array that can be used to tell the
* saver how to save the file, because it can take any number of * saver how to save the file, because it can take any number of
...@@ -247,7 +256,7 @@ public: ...@@ -247,7 +256,7 @@ public:
* *
* @throw IO_ERROR if there is a problem saving or exporting. * @throw IO_ERROR if there is a problem saving or exporting.
*/ */
virtual void Save( const wxString* aFileName, BOARD* aBoard, virtual void Save( const wxString& aFileName, BOARD* aBoard,
PROPERTIES* aProperties = NULL ); PROPERTIES* aProperties = NULL );
//-----</PUBLIC PLUGIN API>------------------------------------------------ //-----</PUBLIC PLUGIN API>------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment