1 /**
2 * This is a simple mechanism to bind Inkscape to Java, and thence
3 * to all of the nice things that can be layered upon that.
4 *
5 * Authors:
6 * Bob Jamison
7 *
8 * Copyright (C) 2007-2008 Bob Jamison
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
25 package org.inkscape.cmn;
27 /**
28 * This is the base of all classes which map to a corresponding
29 * C++ object. The _pointer value is storage for the C++ object's
30 * pointer. Construct() and destruct() are called for when things
31 * need to be setup or cleaned up on the C++ side during creation or
32 * destruction of this object.
33 *
34 * @see BaseInterface for how we add multiple inheritance to classes
35 * which are rooted on this class.
36 */
37 public class BaseObject
38 {
40 private long _pointer;
42 /**
43 * getPointer() means that -any- java instance rooted on
44 * either BaseObject or BaseInterface can call getPointer() to get the
45 * handle to the associated C++ object pointer. The difference is that
46 * BaseObject holds the actual pointer, while BaseInterface refers to
47 * its owner BaseObject.
48 */
49 protected long getPointer()
50 {
51 return _pointer;
52 }
54 /**
55 * sets the pointer to the associated C++ object to a new value
56 */
57 protected void setPointer(long val)
58 {
59 _pointer = val;
60 }
62 protected native void construct();
64 protected native void destruct();
66 protected BaseInterface imbue(BaseInterface intf)
67 {
68 intf.setParent(this);
69 return intf;
70 }
73 /**
74 * Simple constructor
75 */
76 public BaseObject()
77 {
78 construct();
79 }
81 }