Initial work on auto4 implementation.

Originally committed to SVN as r345.
This commit is contained in:
Niels Martin Hansen 2006-04-16 04:05:16 +00:00
parent 8ad3d1d252
commit ca9523af18
4 changed files with 450 additions and 1 deletions

View File

@ -328,3 +328,24 @@ Returns: Boolean.
---
Script information globals
These are a series of global variables, the script author can set. They are
purely informational, and won't have any actual influence on how the script
is treated.
script_name (string)
A short, descriptive name for the script, used for presenting it to the
user in the UI.
script_description (string)
A longer description of the purpose of the script, presented to the user
in the UI.
script_author (string)
Name(s) of the author(s) of the script.
script_version (string)
Version number of the script.
---

230
core/auto4_base.cpp Normal file
View File

@ -0,0 +1,230 @@
// Copyright (c) 2006, Niels Martin Hansen
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// -----------------------------------------------------------------------------
//
// AEGISUB
//
// Website: http://aegisub.cellosoft.com
// Contact: mailto:zeratul@cellosoft.com
//
#include "auto4_base.h"
namespace Automation4 {
// Feature
Feature::Feature(ScriptFeatureClass _featureclass, wxString &_name)
: featureclass(_featureclass), name(_name)
{
// nothing to do
}
ScriptFeatureClass Feature::GetClass() const
{
return featureclass;
}
const FeatureMacro* Feature::AsMacro() const
{
if (featureclass == SCRIPTFEATURE_MACRO)
return static_cast<const FeatureMacro*>(this);
return 0;
}
const FeatureFilter* Feature::AsFilter() const
{
if (featureclass == SCRIPTFEATURE_FILTER)
return static_cast<const FeatureFilter*>(this);
return 0;
}
const FeatureReader* Feature::AsReader() const
{
if (featureclass == SCRIPTFEATURE_READER)
return static_cast<const FeatureReader*>(this);
return 0;
}
const FeatureWriter* Feature::AsWriter() const
{
if (featureclass == SCRIPTFEATURE_WRITER)
return static_cast<const FeatureWriter*>(this);
return 0;
}
const wxString& Feature::GetName() const
{
return name;
}
// FeatureMacro
FeatureMacro::FeatureMacro(wxString &_name, wxString &_description, MacroMenu _menu)
: Feature(SCRIPTFEATURE_MACRO, _name), description(_description), menu(_menu)
{
// nothing to do
}
const wxString& FeatureMacro::GetDescription() const
{
return description;
}
MacroMenu FeatureMacro::GetMenu() const
{
return menu;
}
// FeatureFilter
FeatureFilter::FeatureFilter(wxString &_name, wxString &_description, int _priority)
: Feature(SCRIPTFEATURE_FILTER, _name), description(_description), priority(_priority)
{
// nothing to do
}
const wxString& FeatureFilter::GetDescription() const
{
return description;
}
int FeatureFilter::GetPriority() const
{
return priority;
}
// FeatureReader
FeatureReader::FeatureReader(wxString &_name, wxString &_extension, bool _is_text_format)
: Feature(SCRIPTFEATURE_READER, _name), extension(_extension), is_text_format(_is_text_format)
{
// nothing to do
}
const wxString& FeatureReader::GetExtension() const
{
return extension;
}
bool FeatureReader::GetIsTextFormat() const
{
return is_text_format;
}
// FeatureWriter
FeatureWriter::FeatureWriter(wxString &_name, wxString &_extension, bool _is_text_format)
: Feature(SCRIPTFEATURE_WRITER, _name), extension(_extension), is_text_format(_is_text_format)
{
// nothing to do
}
const wxString& FeatureWriter::GetExtension() const
{
return extension;
}
bool FeatureWriter::GetIsTextFormat() const
{
return is_text_format;
}
// Script
Script::Script(wxString &_filename)
: filename(_filename), name(_T("")), description(_T("")), author(_T("")), version(_T(""))
{
// nothing to do..?
}
const wxString& Script::GetFilename() const
{
return filename;
}
const wxString& Script::GetName() const
{
return name;
}
const wxString& Script::GetDescription() const
{
return description;
}
const wxString& Script::GetAuthor() const
{
return author;
}
const wxString& Script::GetVersion() const
{
return version;
}
const std::vector<Feature*> Script::GetFeatures() const
{
return features;
}
// ScriptManager
ScriptManager::ScriptManager()
{
// do nothing...?
}
ScriptManager::~ScriptManager()
{
// do nothing...?
}
void ScriptManager::Add(Script *script)
{
// TODO
}
void ScriptManager::Remove(Script *script)
{
// TODO
}
const std::vector<Feature*>& ScriptManager::GetMacros(MacroMenu menu) const
{
return macros[menu];
}
};

198
core/auto4_base.h Normal file
View File

@ -0,0 +1,198 @@
// Copyright (c) 2006, Niels Martin Hansen
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// -----------------------------------------------------------------------------
//
// AEGISUB
//
// Website: http://aegisub.cellosoft.com
// Contact: mailto:zeratul@cellosoft.com
//
#pragma once
#ifndef AUTO4_CORE_H
#define AUTO4_CORE_H
#include <wx/string.h>
#include <vector>
namespace Automation4 {
enum MacroMenu {
MACROMENU_NONE = 0,
MACROMENU_ALL = 0,
MACROMENU_EDIT,
MACROMENU_VIDEO,
MACROMENU_AUDIO,
MACROMENU_TOOLS,
MACROMENU_RIGHT,
MACROMENU_MAX // must be last
};
enum ScriptFeatureClass {
SCRIPTFEATURE_MACRO = 0,
SCRIPTFEATURE_FILTER,
SCRIPTFEATURE_READER,
SCRIPTFEATURE_WRITER,
SCRIPTFEATURE_MAX // must be last
};
class FeatureMacro;
class FeatureFilter;
class FeatureReader;
class FeatureWriter;
class Feature {
private:
ScriptFeatureClass featureclass;
wxString name;
protected:
Feature(ScriptFeatureClass _featureclass, wxString &_name);
public:
ScriptFeatureClass GetClass() const;
const FeatureMacro* AsMacro() const;
const FeatureFilter* AsFilter() const;
const FeatureReader* AsReader() const;
const FeatureWriter* AsWriter() const;
const wxString& GetName() const;
};
class FeatureMacro : public Feature {
private:
wxString description;
MacroMenu menu;
protected:
FeatureMacro(wxString &_name, wxString &_description, MacroMenu _menu);
public:
const wxString& GetDescription() const;
MacroMenu GetMenu() const;
virtual bool Validate(/* TODO: this needs arguments */) = 0;
virtual void Process(/* TODO: this needs arguments */) = 0;
};
class FeatureFilter : public Feature { // TODO: also inherit from export filter class?
private:
wxString description;
int priority;
protected:
FeatureFilter(wxString &_name, wxString &_description, int _priority);
public:
const wxString& GetDescription() const;
int GetPriority() const;
virtual void GetOptionsWindow(/* TODO: this needs arguments */) = 0; // TODO: return type
virtual void Process(/* TODO: this needs arguments */) = 0;
};
class FeatureReader : public Feature { // TODO: also inherit from SubtitleFormat class?
private:
wxString extension;
bool is_text_format;
protected:
FeatureReader(wxString &_name, wxString &_extension, bool _is_text_format);
public:
const wxString& GetExtension() const;
bool GetIsTextFormat() const;
virtual void Process(/* TODO: this needs arguments */) = 0; // TODO: return type
};
class FeatureWriter : public Feature { // TODO: also inherit from SubtitleFormat class?
private:
wxString extension;
bool is_text_format;
protected:
FeatureWriter(wxString &_name, wxString &_extension, bool _is_text_format);
public:
const wxString& GetExtension() const;
bool GetIsTextFormat() const;
virtual void Process(/* TODO: this needs arguments */) = 0; // TODO: return type
};
class Script {
private:
wxString filename;
protected:
wxString name;
wxString description;
wxString author;
wxString version;
std::vector<Feature*> features;
Script(wxString &_filename);
public:
virtual void Reload() = 0;
const wxString& GetFilename() const;
const wxString& GetName() const;
const wxString& GetDescription() const;
const wxString& GetAuthor() const;
const wxString& GetVersion() const;
const std::vector<Feature*> GetFeatures() const;
};
class ScriptManager {
private:
/*struct ScriptRecord {
Script *script;
int priority;
};*/
typedef Script* ScriptRecord;
std::vector<ScriptRecord> scripts;
std::vector<Feature*> macros[MACROMENU_MAX]; // array of vectors...
public:
ScriptManager();
~ScriptManager();
void Add(Script *script);
void Remove(Script *script);
const std::vector<Feature*>& GetMacros(MacroMenu menu) const;
};
};
#endif

View File

@ -1,4 +1,4 @@
// Copyright (c) 2005, Niels Martin Hansen
// Copyright (c) 2005, 2006, Niels Martin Hansen
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without