2014-04-09 17:43:14 +04:00
|
|
|
namespace LAview {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface of any LaTeX Document.
|
|
|
|
*/
|
|
|
|
public interface IDoc : Object {
|
|
|
|
|
|
|
|
/**
|
2014-07-25 18:30:55 +04:00
|
|
|
* Gets a copy of the ``IDoc``.
|
2014-04-09 17:43:14 +04:00
|
|
|
*/
|
|
|
|
public abstract IDoc copy ();
|
|
|
|
|
|
|
|
/**
|
2014-07-25 18:30:55 +04:00
|
|
|
* Generates LaTeX string for the ``IDoc``.
|
2014-04-09 17:43:14 +04:00
|
|
|
*/
|
|
|
|
public abstract string generate ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Any non-iterable LaTeX Document.
|
|
|
|
*/
|
|
|
|
public abstract class ADoc : Object, IDoc {
|
|
|
|
|
|
|
|
protected ADoc () {}
|
|
|
|
|
|
|
|
/**
|
2014-07-25 18:30:55 +04:00
|
|
|
* Gets a copy of the ``ADoc``.
|
2014-04-09 17:43:14 +04:00
|
|
|
*/
|
|
|
|
public virtual IDoc copy () {
|
|
|
|
return Object.new (this.get_type ()) as IDoc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-25 18:30:55 +04:00
|
|
|
* Generates LaTeX string for the ``ADoc``.
|
2014-04-09 17:43:14 +04:00
|
|
|
*/
|
|
|
|
public virtual string generate () { return ""; }
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Any iterable LaTeX Document.
|
|
|
|
*/
|
|
|
|
public abstract class ADocList : Gee.ArrayList<IDoc>, IDoc {
|
|
|
|
|
|
|
|
protected ADocList () {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Object.new (this.get_type ()) doesn't work for me for ArrayList.
|
|
|
|
*/
|
|
|
|
protected abstract ADocList create_default_instance ();
|
|
|
|
|
|
|
|
/**
|
2014-07-25 18:30:55 +04:00
|
|
|
* Gets a copy of the ``ADocList``.
|
2014-04-09 17:43:14 +04:00
|
|
|
*/
|
|
|
|
public virtual IDoc copy () {
|
|
|
|
var clone = create_default_instance ();
|
|
|
|
|
|
|
|
foreach (IDoc dociface in this)
|
|
|
|
clone.add (dociface.copy () as IDoc);
|
|
|
|
|
|
|
|
return clone;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-25 18:30:55 +04:00
|
|
|
* Generates LaTeX string for the ``ADocList``.
|
2014-04-09 17:43:14 +04:00
|
|
|
*/
|
|
|
|
public virtual string generate () {
|
|
|
|
var result = new StringBuilder ();
|
|
|
|
|
|
|
|
foreach (IDoc dociface in this)
|
|
|
|
result.append (dociface.generate ());
|
|
|
|
|
|
|
|
return result.str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|