sp-object.h revision 037770d289d0ef4c78c279e1dd3f3b4f2140c751
#ifndef SP_OBJECT_H_SEEN
#define SP_OBJECT_H_SEEN
/** \file
* Abstract base class for all nodes
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
*
* Copyright (C) 1999-2002 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
/* SPObject flags */
/* Async modification flags */
#define SP_OBJECT_MODIFIED_FLAG (1 << 0)
/* Conveneience */
#define SP_OBJECT_FLAGS_ALL 0xff
/* Flags that mark object as modified */
/* Object, Child, Style, Viewport, User */
/* Flags that will propagate downstreams */
/* Parent, Style, Viewport, User */
#define SP_OBJECT_MODIFIED_CASCADE (SP_OBJECT_FLAGS_ALL & ~(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))
/* Generic */
/* Write flags */
#define SP_OBJECT_WRITE_BUILD (1 << 0)
/* Convenience stuff */
#include <glib-object.h>
#include <sigc++/connection.h>
#include "forward.h"
#include "version.h"
#include "util/forward-pointer-iterator.h"
}
}
typedef enum {
/// An attempt to implement exceptions, unused?
struct SPException {
};
/// Unused
struct SPCtx {
unsigned int flags;
};
enum {
};
/// Internal class consisting of two bits.
struct SPIXmlSpace {
};
/*
* Refcounting
*
* Owner is here for debug reasons, you can set it to NULL safely
* Ref should return object, NULL is error, unref return always NULL
*/
/// A refcounting tree node object.
enum CollectionPolicy {
};
unsigned int cloned : 1;
unsigned int uflags : 8;
unsigned int mflags : 8;
unsigned int hrefcount; /* number of xlink:href references */
unsigned int _total_hrefcount; /* our hrefcount + total descendants */
/** @brief cleans up an SPObject, releasing its references and
* requesting that references to it be released
*/
void releaseReferences();
/** @brief connects to the release request signal
*
* @param slot the slot to connect
*
* @returns the sigc::connection formed
*/
}
/**
* Represents the style properties, whether from presentation attributes, the <tt>style</tt>
* attribute, or inherited.
*
* sp_object_private_set doesn't handle SP_ATTR_STYLE or any presentation attributes at the
* time of writing, so this is probably NULL for all SPObject's that aren't an SPItem.
*
* However, this gives rise to the bugs mentioned in sp_object_get_style_property.
* Note that some non-SPItem SPObject's, such as SPStop, do need styling information,
* and need to inherit properties even through other non-SPItem parents like \<defs\>.
*/
/// Switch containing next() method.
struct ParentIteratorStrategy {
}
};
/// Switch containing next() method.
struct SiblingIteratorStrategy {
}
};
typedef Inkscape::Util::ForwardPointerIterator<SPObject const, ParentIteratorStrategy> ConstParentIterator;
typedef Inkscape::Util::ForwardPointerIterator<SPObject const, SiblingIteratorStrategy> ConstSiblingIterator;
}
/* A non-const version can be similarly constructed if you want one.
* (Don't just cast away the constness, which would be ill-formed.) */
/** @brief Retrieves children as a GSList */
/** @brief Gets the author-visible label for this object. */
/** @brief Returns a default label for this object. */
gchar const *defaultLabel() const;
/** @brief Sets the author-visible label for this object.
*
* Sets the author-visible label for the object.
*
* @param label the new label
*/
/** Retrieves the title of this object */
/** Sets the title of this object */
/** Retrieves the description of this object */
/** Sets the description of this object */
/** @brief Set the policy under which this object will be
* orphan-collected.
*
* Orphan-collection is the process of deleting all objects which no longer have
* hyper-references pointing to them. The policy determines when this happens. Many objects
* should not be deleted simply because they are no longer referred to; other objects (like
* "intermediate" gradients) are more or less throw-away and should always be collected when no
* longer in use.
*
* Along these lines, there are currently two orphan-collection policies:
*
* COLLECT_WITH_PARENT - don't worry about the object's hrefcount;
* if its parent is collected, this object
* will be too
*
* COLLECT_ALWAYS - always collect the object as soon as its
* hrefcount reaches zero
*
* @returns the current collection policy in effect for this object
*/
/** @brief Sets the orphan-collection policy in effect for this object.
*
* @see SPObject::collectionPolicy
*
* @param policy the new policy to adopt
*/
}
/** @brief Requests a later automatic call to collectOrphan().
*
* This method requests that collectOrphan() be called during the document update cycle,
* deleting the object if it is no longer used.
*
* If the current collection policy is COLLECT_WITH_PARENT, this function has no effect.
*
* @see SPObject::collectOrphan
*/
void requestOrphanCollection();
/** @brief Unconditionally delete the object if it is not referenced.
*
* Unconditionally delete the object if there are no outstanding hyper-references to it.
* Observers are not notified of the object's deletion (at the SPObject level; XML tree
* notifications still fire).
*
* @see SPObject::deleteObject
*/
void collectOrphan() {
if ( _total_hrefcount == 0 ) {
deleteObject(false);
}
}
/** @brief Check if object is referenced by any other object.
*/
bool isReferenced() { return ( _total_hrefcount > 0 ); }
/** @brief Deletes an object.
*
* Detaches the object's repr, and optionally sends notification that the object has been
* deleted.
*
* @param propagate notify observers that the object has been deleted?
*
* @param propagate_descendants notify observers of children that they have been deleted?
*/
/** @brief Deletes on object.
*
* @param propagate Notify observers of this object and its children that they have been
* deleted?
*/
void deleteObject(bool propagate=true) {
}
/** @brief Connects a slot to be called when an object is deleted.
*
* This connects a slot to an object's internal delete signal, which is invoked when the object
* is deleted
*
* The signal is mainly useful for e.g. knowing when to break hrefs or dissociate clones.
*
* @param slot the slot to connect
*
* @see SPObject::deleteObject
*/
}
}
/** @brief Returns the object which supercedes this one (if any).
*
* This is mainly useful for ensuring we can correctly perform a series of moves or deletes,
* even if the objects in question have been replaced in the middle of the sequence.
*/
/** @brief Indicates that another object supercedes this one. */
}
/* modifications; all three sets of methods should probably ultimately be protected, as they
* are not really part of its public interface. However, other parts of the code to
* occasionally use them at present. */
/* the no-argument version of updateRepr() is intended to be a bit more public, however -- it
* essentially just flushes any changes back to the backing store (the repr layer); maybe it
* should be called something else and made public at that point. */
/** @brief Updates the object's repr based on the object's state.
*
* This method updates the the repr attached to the object to reflect the object's current
* state; see the three-argument version for details.
*
* @param flags object write flags that apply to this update
*
* @return the updated repr
*/
/** @brief Updates the given repr based on the object's state.
*
* This method updates the given repr to reflect the object's current state. There are
* several flags that affect this:
*
* SP_OBJECT_WRITE_BUILD - create new reprs
*
* SP_OBJECT_WRITE_EXT - write elements and attributes
* which are not part of pure SVG
* (i.e. the Inkscape and Sodipodi
* namespaces)
*
* SP_OBJECT_WRITE_ALL - create all nodes and attributes,
* even those which might be redundant
*
* @param repr the repr to update
* @param flags object write flags that apply to this update
*
* @return the updated repr
*/
Inkscape::XML::Node *updateRepr(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags);
/** @brief Queues an deferred update of this object's display.
*
* This method sets flags to indicate updates to be performed later, during the idle loop.
*
* There are several flags permitted here:
*
* SP_OBJECT_MODIFIED_FLAG - the object has been modified
*
* SP_OBJECT_CHILD_MODIFIED_FLAG - a child of the object has been
* modified
*
* SP_OBJECT_STYLE_MODIFIED_FLAG - the object's style has been
* modified
*
* There are also some subclass-specific modified flags which are hardly ever used.
*
* One of either MODIFIED or CHILD_MODIFIED is required.
*
* @param flags flags indicating what to update
*/
void requestDisplayUpdate(unsigned int flags);
/** @brief Updates the object's display immediately
*
* This method is called during the idle loop by SPDocument in order to update the object's
* display.
*
* One additional flag is legal here:
*
* SP_OBJECT_PARENT_MODIFIED_FLAG - the parent has been
* modified
*
* @param ctx an SPCtx which accumulates various state
* during the recursive update -- beware! some
* subclasses try to cast this to an SPItemCtx *
*
* @param flags flags indicating what to update (in addition
* to any already set flags)
*/
/** @brief Requests that a modification notification signal
* be emitted later (e.g. during the idle loop)
*
* @param flags flags indicating what has been modified
*/
void requestModified(unsigned int flags);
/** @brief Emits a modification notification signal
*
* @param flags indicating what has been modified
*/
void emitModified(unsigned int flags);
/** @brief Connects to the modification notification signal
*
* @param slot the slot to connect
*
* @returns the connection formed thereby
*/
) {
}
void _sendDeleteSignalRecursive();
void _updateTotalHRefCount(int increment);
}
// Private member functions used in the definitions of setTitle(),
// setDesc(), title() and desc().
GString * textualContent() const;
};
/// The SPObject vtable.
struct SPObjectClass {
/* Virtual handlers of repr signals */
void (* order_changed) (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *new_repr);
/* Update handler */
/* Modification handler */
Inkscape::XML::Node * (* write) (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags);
};
/*
*/
return parent->firstChild();
}
void sp_object_invoke_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned);
/* Public */
void sp_object_setAttribute(SPObject *object, gchar const *key, gchar const *value, SPException *ex);
/* Style */
#endif // SP_OBJECT_H_SEEN
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :