File: object.h

package info (click to toggle)
gnome-chemistry-utils 0.14.9-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 17,836 kB
  • ctags: 7,337
  • sloc: cpp: 72,977; sh: 11,381; xml: 6,304; makefile: 1,663; ansic: 1,061
file content (756 lines) | stat: -rw-r--r-- 24,811 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
// -*- C++ -*-

/*
 * Gnome Chemistry Utils
 * object.h
 *
 * Copyright (C) 2002-2011 Jean Bréfort <jean.brefort@normalesup.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */

#ifndef GCU_OBJECT_H
#define GCU_OBJECT_H

#include "macros.h"
#include "matrix2d.h"
#include <libxml/parser.h>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stdexcept>

#define square(x) ((x)*(x))

/*!\file*/
namespace gcu
{

class Dialog;
class Application;
class UIManager;

/*!\enum GcuTypeId
This enumeration is used to determine the type of an Object instance.
Possible values are:
	- NoType invalid type
	- AtomType an atom
	- FragmentType several atoms linked and represented by a text such as COOH (only in GChemPaint).
	- BondType a bond between two (or more) atoms.
	- MoleculeType a molecule.
	- ChainType a chain of atoms.
	- CycleType a cycle.
	- ReactantType a molecule involved in a reaction (only in GChemPaint).
	- ReactionArrowType a reaction arrow (only in GChemPaint).
	- ReactionOperatorType a + sign in a reaction (only in GChemPaint).
	- ReactionType a reaction.
	- MesomeryType a mesomery representation (only in GChemPaint).
	- MesomeryArrowType a double headed arrow used to represent mesomery (only in GChemPaint).
	- DocumentType a document, generally the top node in the objects tree.
	- TextType some text (only in GChemPaint).
	- OtherType if the type of an object is at least equal to OtherType, then it is a dynamically created type returned
	by the static Object::AddType method.
	.
Some types are not used in  the Gnome Chemistry Utils, but only in GChemPaint
and might disappear from this list in future versions and replaced by dynamically created types.
*/
enum GcuTypeId
{
	NoType,
	AtomType,
	FragmentType,
	BondType,
	MoleculeType,
	ChainType,
	CycleType,
	ReactantType,
	ReactionArrowType,
	ReactionOperatorType,
	ReactionType,
	MesomeryType,
	MesomeryArrowType,
	DocumentType,
	TextType,
	OtherType
};

/*!
The type of an object instance. Either predefined types are defined in the enum above
or dynamically defined types by calls to Object::AddType.
*/
typedef unsigned TypeId;

class Object;

/*!
The type of callbacks for adding new items to the contextual menu of an object.
@param target the Object whose menu is being built.
@param uim the UIManager to populate.
@param object the Object on which occured the mouse click.
@param x x coordinate of the mouse click.
@param y y coordinate of the mouse click.
*/
// FIXME: create a class for UIManager
typedef bool (*BuildMenuCb) (Object *target, UIManager *uim, Object *object, double x, double y);

class TypeDesc
{
public:
	TypeDesc ();

	TypeId Id;
	Object* (*Create) ();
	std::set <TypeId> PossibleChildren;
	std::set <TypeId> PossibleParents;
	std::set <TypeId> RequiredChildren;
	std::set <TypeId> RequiredParents;
	std::string CreationLabel;
	std::list <BuildMenuCb> MenuCbs;
};

class Object;

/*!\enum RuleId
This enumeration is used to maintain a set of rules about the possible
hierarchical of the document. They are used with two class names or ids.
Possible values are:
	- RuleMayContain an instance of the first class may contain an instance of the second.
This implies that an instance of the second class may be in an instance of the first (see RuleMayBeIn);
	- RuleMustContain an instance of the first class may contain an instance of the second class (implies RuleMayContain);
if no instance of the first class is present, the object is not valid.
	- RuleMayBeIn an instance of the first class may be the child of an instance of the second class (see also RuleMayContain);
	- RuleMustBeIn an instance of the first class must be the child of an instance of the second class, otherwise
it is not valid.
*/
enum RuleId
{
	RuleMayContain,
	RuleMustContain,
	RuleMayBeIn,
	RuleMustBeIn
};

/*!
The types of the signals used in Object::EmitSignal() and Object::OnSignal(). Each signal
must type be retrieved from a call to Object::CreateNewSignalId().
*/
typedef unsigned SignalId;

class Document;

/*!\class Object gcu/object.h
This is the base class for most other objects in the gcu namespace.
*/
class Object
{
friend class Application;
public:
/*!
Used to create an object of type Id. Should only be called from the constructor of a derived class.
*/
	Object (TypeId Id = OtherType);
/*!
The standard destructor of Object instances. Automatically called when the object is destroyed.
*/
	virtual ~Object ();

/*!
@return the type of the object. If the type is at least equal to OtherType, it is a dynamically created type returned by
the Object::AddType method.
*/
	TypeId GetType () const {return m_Type;}
/*!
	@param Id the id of the Object instance.

	Every object must have an Id, since searches in the document tree uses it.
*/
	void SetId (gchar const *Id);
/*!
	@return the Id of the Object instance.
*/
	char const *GetId () const {return m_Id;}
/*!
	@param object the Object instance to add as a child.

	Each Object instance maintains a list of its children. If object has already a parent, it will be removed from its
	parent children list. The new parent Object must have a Document ancestor to ensure that Ids are unique.
*/
	virtual void AddChild (Object* object);
/*!
	Used to get the Molecule in the Object instances ancestors.  Overloaded methods should call the
	base class Object::AddChild.

	@return the first Object of type MoleculeType encountered when exploring
	the Objects tree or NULL if none is found.
*/
	Object* GetMolecule () const;
/*!
	Used to get the Reaction in the Object instances ancestors.

	@return the first Object of type ReactionType encountered when exploring
	the Objects tree or NULL if none is found.
*/
	Object* GetReaction () const;
/*!
	Used to get the highest ancestor just before the document
	in the Object instances ancestors.

	@return the last Object encountered before the document when exploring
	the Objects tree or NULL if the object's parent is the document itself.
*/
	Object* GetGroup () const;
/*!
	Used to get the Document in the Object instances ancestors.

	@return the first Object of type DocumentType encountered when exploring
	the Objects tree (only one should be found) or NULL if none is found.
*/
	Document* GetDocument () const;
/*!
	Used to get the Application owning the Object.

	@return the Application owning the Object or NULL.
*/
	Application* GetApplication () const;
/*!
@param Id the type of the ancestor searched.

	Used to get the first ancestor of type Id in the Object instances ancestors.
	GetDocument, GetMolecule and GetReaction are special cases of this method.

	@return the first Object of type Id encountered when exploring
	the Objects tree (only one should be found) or NULL if none is found.
*/
	Object* GetParentOfType (TypeId Id) const;
/*!
@param Id the Id of the child searched.

To search the Object in lower shells of the tree, use the Object::GetDescendant method.
@return the Object instance of type Id if found in the children list or NULL if not found.
*/
	Object* GetChild (const gchar* Id) const;
/*!
@param i a C++ std::map iterator.

Use this function to retrieve the first child of the object and initialize the iterator.
@return the first child of the object or NULL.
*/
	Object *GetFirstChild (std::map<std::string, Object*>::iterator& i);
	Object const *GetFirstChild (std::map<std::string, Object*>::const_iterator& i) const;
/*!
@param i a C++ std::map iterator initialized by Object::GetFirstChild.

Use this method to iterate through the list of the Object children.
@return the next child of the object or NULL.
*/
	Object *GetNextChild (std::map<std::string, Object*>::iterator& i);
	Object const *GetNextChild (std::map<std::string, Object*>::const_iterator& i) const;
/*!
@param Id the Id of the descendant searched.

This method searches the Object in its children and if not found calls the GetDescendant method for its children.
@return the Object instance of type Id if found in the decendants or NULL if not found.
*/
	Object* GetDescendant (const char* Id) const;
/*!
@return the parent of the Object.
*/
	Object* GetParent () const {return m_Parent;};
/*!
@param Parent the new parent of the Object or NULL.

	When Parent is not NULL, this is equivalent to \code Parent->AddChild(this);\endcode
	Otherwise, it removes the Object from the Document tree.
*/
	void SetParent (Object* Parent);
/*!
	@param xml the xmlDoc used to save the document.

	Used to save the Object to the xmlDoc. Each serializable Object should implement this virtual method.
	@return the xmlNode containing the serialized object. The name of the node should be the name of the
	corresponding type used as first parameter to the Object::AddType method. The
	default method just saves the id and children.
*/
	virtual xmlNodePtr Save (xmlDocPtr xml) const;
/*!
@param node a pointer to the xmlNode containing the serialized object.

Used to load an Object in memory. The Object must already exist.

Example: \code
	std::string str = (const char*)node->name;
	Object* pObject = Object::CreateObject(str, this);
	if (pObject) {
		if (!pObject->Load(node)) delete Object;
	} else
		cerr << "Warning: unknown object: " << str << endl;
\endcode

@return true on succes, false otherwise.
*/
	virtual bool Load (xmlNodePtr node);
/*!
@param x a pointer to the double value which will receive the x coordinate of the Object.
@param y a pointer to the double value which will receive the y coordinate of the Object.
@param z a pointer to the double value which will receive the z coordinate of the Object or NULL for 2D representations.

Retrieves the coordinates of this Object if relevant.
@return true if successful and false if an error occurs (if x or y is NULL).
*/
	virtual bool GetCoords (double *x, double *y, double *z = NULL) const;
/*!
@param x the x component of the transation vector.
@param y the y component of the transation vector.
@param z the z component of the transation vector.

Used to move an object. This virtual method should most often be overrided by Object derived classes for which it makes sense.
The base Object class has no coordinates and the default method only loads its id and children.
*/
	virtual void Move (double x, double y, double z = 0.);
/*!
@param m the Matrix2D of the transformation.
@param x the x component of the center of the transformation.
@param y the y component of the center of the transformation.

Used to move and/or transform an object.
This virtual method must be overrided by Object derived classes for which it makes sense.
The base Object class has no coordinates and the default method calls the corresponding method
for every child.
*/
	virtual void Transform2D (Matrix2D& m, double x, double y);
/*!
@param xml the xmlDoc used to save the document.
@param node the node representing the Object.

This method calls Object::Save fo each child of the Object instance and add the xmlNode returned to the children of node.
It might be called from the Save method of objects having serializable children.
@return true on succes, false otherwise.
*/
	bool SaveChildren (xmlDocPtr xml, xmlNodePtr node) const;
/*!
@param node the node representing the Object.

This helper method saves the Id of the node as a property of the xmlNode.
*/
	void SaveId (xmlNodePtr node) const;
/*!
@param node the node where the search is to be done.
@param Property the name of the property used in the search.
@param Id the value to match to the property.

Helper method used in conjunction with Object::GetNextNodeByProp to search xmlNode instances having a property Property
whose value is Id in the children of node.

@return the node corresponding to the first match. This value is to be passed to Object::GetNextNodeByProp to iterate in the list
*/
	xmlNodePtr GetNodeByProp (xmlNodePtr node, char const *Property, char const *Id);
/*!
@param node the xmlNodePtr returned by Object::GetNodeByProp or the last call to Object::GetNextNodeByProp.
@param Property the name of the property used in the search.
@param Id the value to match to the property.

Helper method used to iterate through a list of xmlNodePtr searching for a special value of a property.
Generally, the iteration is initialized by a call to Object::GetNodeByProp.
@return the next matching node.
*/
	xmlNodePtr GetNextNodeByProp (xmlNodePtr node, char const *Property, char const *Id);
/*!
@param node the node where the search is to be done.
@param Name the name of the xmlNode searched.

Helper method used in conjunction with Object::GetNextNodeByProp to search xmlNode instances of name Name
in the children of node.

@return the node corresponding to the first match. This value is to be passed to Object::GetNextNodeByName to iterate in the list.
*/
	xmlNodePtr GetNodeByName (xmlNodePtr node, char const *Name);
/*!
@param node the xmlNodePtr returned by Object::GetNodeByName or the last call to Object::GetNextNodeByName.
@param Name the name of the xmlNode searched.

Helper method used to iterate through a list of xmlNodePtr searching for nodes whose name is Name.
Generally, the iteration is initialized by a call to Object::GetNodeByName.
@return the next matching node.
*/
	xmlNodePtr GetNextNodeByName (xmlNodePtr node, char const *Name);
/*!
@return true if the Object has at least a child an false if it has none.
*/
	bool HasChildren () const {return m_Children.size () != 0;}

/*!
@return the children number of the Object.
*/
	unsigned GetChildrenNumber () const {return m_Children.size ();}

/*!
@param x the x coordinate
@param y the y coordinate
@param z the z coordinate

@return a pointer to a child of type Atomtype at or near position defined by the coordinates
passed as parameters. Default implementation returns NULL.
*/
	virtual Object* GetAtomAt (double x, double y, double z = 0.);

/*!
@param Children the list of objects used as children to build the object

This method is called to build a parent object from its children. The object must already exist.
@return true in case of success and false if failed.
*/
	virtual bool Build (std::set < Object * > const &Children) throw (std::invalid_argument);

/*!
Used to retrieve the y coordinate for alignment. The default implementation returns 0.0 and
every derived class for which alignment has a meaning should implement this method.
@return y coordinate used for objects alignment.
*/
	virtual double GetYAlign ();

/*!
@param uim the UIManager to populate.
@param object the Object on which occured the mouse click.
@param x x coordinate of the mouse click.
@param y y coordinate of the mouse click.

This method is called to build a contextual menu for the object. It is called by Object::ShowContextualMenu, so
it should not be necessary to call it directly. It should be overriden by derived classes when a contextual menu
is needed. Typically, each class adds a submenu and calls the same method for its parent.
Default implementation calls registered BuildMenuCb callbacks and the parent's method.
Derived classes should call Object::BuildContextualMenu before returning.
@return true if something is added to the UIManager, false otherwise.
*/
	virtual bool BuildContextualMenu (UIManager *uim, Object *object, double x, double y);

/*!
@param Signal the appropriate SignalId

Sends a signal to the object parent. The signal may be propagated to the ancestors (see
Object::OnSignal ()).
*/
	void EmitSignal (SignalId Signal);

/*!
@param Signal the appropriate SignalId
@param Child the child which emitted the signal or NULL

This function is called by the framework when a signal has been emitted for the object.
It should not be called by a program; call Object::EmitSignal instead.

@return true if the signal should be propagated to the parent, false otherwise.
*/
	virtual bool OnSignal (SignalId Signal, Object *Child);

/*!
@param state whether to block signals or not

Blocks signals if State is true and unblocs if state is false.

Since 0.4.2
*/
	void Lock (bool state = true);

/*!

@return true if signals are locked, false otherwise

Since 0.4.2
*/
	bool IsLocked () {return m_Locked > 0;}

/*!
@param i a C++ std::set<Object*> iterator.

Use this function to retrieve the first object linked to the object and initialize the iterator.
Links can be used when the relation between the objects is not a parent to child one.
@return the first object linked to the object or NULL.
*/
	Object* GetFirstLink (std::set<Object*>::iterator& i);

/*!
@param i a C++ std::set<Object*> iterator initialized by Object::GetFirstLink.

Use this method to iterate through the list of Object instances linked to the object.
@return the next object linked to the object or NULL.
*/
	Object* GetNextLink (std::set<Object*>::iterator& i);

/*!
@param object the object to link.

Adds a link to \a object.
*/
	void Link (Object *object);

/*!
@param object the object to unlink.

Unlinks object and calls Object::OnUnlink.
*/
	void Unlink (Object *object);

/*!
@param object the object just unlinked by Object::Unlink.

Virtual method called when an object has been unlinked. Programs should not call it
directly, but should call Object::OnUnlink instead.
*/
	virtual void OnUnlink (Object *object);

/*!
@param types the list of TypeId values to fill

Fills types with all valid ancestor types for the object as defined by rules created with AddRule
*/
	void GetPossibleAncestorTypes (std::set<TypeId>& types) const;

/*!
@param property the property id as defined in objprops.h
@param value the property value as a string

Used when loading to set properties to various objects. If the method returns false,
the property should be set again later. This might happen if an atom does not exists when one
of its bonds is loaded. All classes supporting the mechanism must overload this method.
@return true if the property could be set, or if the property is not relevant, false otherwise.
*/
	virtual bool SetProperty (unsigned property, char const *value);

/*!
@param property the property id as defined in objprops.h

Used when saving to get properties from various objects. All classes
supporting the mechanism must overload this method.
*/
	virtual std::string GetProperty (unsigned property) const;

/*!
This method should be called when an object has been fully loaded. The default method doesn't do anything.
*/
	virtual void OnLoaded ();

/*!
@param dirty should be true if the object needs some update, false otherwise. For a document,
it  means that the document has been changed.
*/
	void SetDirty (bool dirty = true);

/*!
Deletes all children. Derived classes might override this method if needed.
*/
	virtual void Clear ();

/*!
@return the object generic name.
*/
	virtual std::string Name ();

/*!
@return the object identity composed of the object name as returned by
gcu::Object::Name() concatenated with its unique Id as returned by gcu::Object::GetId().
*/
	std::string Identity ();

/*!
@return the name of the properties dialog for this object if one exists, or NULL.
*/
	virtual char const *HasPropertiesDialog () const;

/*!
@return true if the object can be safely selected. Default implementation returns true.
*/
	virtual bool CanSelect () const {return true;}

/*!
Called by Object::Destructor() when the parent becomes empty. Default implementation does
nothing.
*/
	virtual void NotifyEmpty () {;}

/*!
Exposes the gcu::Dialog related to the object properties if it exists.
*/
	void ShowPropertiesDialog ();

/*!
@param TypeName the name of the new type.
@param CreateFunc a pointer to a function returning a pointer to a new object of the new type.
@param id the Id of the type to create if a standard one or OtherType for a new type. In this last case, this parameter
can be omitted.

This method is used to register a new type derived from Object.

This method is deprecated, use Application::AddType() instead.

@return the Id of the new type.
*/
	static TypeId AddType (std::string TypeName, Object* (*CreateFunc) (), TypeId id = OtherType);

/*!
@param id the Id of an existing type.
@param TypeName a new name for the type.

This method is used to add an alternative name to an existing type.
*/
	static void AddAlias (TypeId id, std::string TypeName);

/*!
@param TypeName the name of the new type.
@param parent the parent of the newly created object or NULL. if NULL, the parameter can be omitted.

Used to create an object of type name TypeName. The Object::AddType method must have been called with the same
TypeName parameter. if parent is given and not NULL, the new Object will be a child of parent.
It will also be given a default Id.

This method is deprecated, use Application::CreateObject() instead.

@return a pointer to the newly created Object or NULL if the Object could not be created.
*/
	static Object* CreateObject (const std::string& TypeName, Object* parent = NULL);

/*!
@param Name the name of the Object derived class

@return the TypeId corresponding to Name
*/
	static TypeId GetTypeId (const std::string& Name);

/*!
@param Id the TypeId of the Object derived class

@return the name of the type.
*/
	static std::string GetTypeName (TypeId Id);

/*!
@param Id the TypeId of the Object derived class
@param cb the BuildMenuCb callback to call when building the menu.

adds a callback for modifying the contextual menu of objects of type Id.

This method is deprecated, use Application::AddMenuCallback() instead.
*/
	static void AddMenuCallback (TypeId Id, BuildMenuCb cb);

/*!
@param type1 the TypeId of the first class in the rule
@param rule the new rule value
@param type2 the TypeId of the second class in the rule

This method is deprecated, use Application::AddRule() instead.

Adds a rule.
*/
	static void AddRule (TypeId type1, RuleId rule, TypeId type2);

/*!
@param type1 the name of the first class in the rule
@param rule the new rule value
@param type2 the name of the second class in the rule

This method is deprecated, use Application::AddRule() instead.

Adds a rule.
*/
	static void AddRule (const std::string& type1, RuleId rule, const std::string& type2);

/*!
@param type the TypeId of a class
@param rule a RuleId value

This method is deprecated, use Application::GetRules() instead.

@return the set of rules correponding to the RuleId value for this class.
*/
	static  const std::set<TypeId>& GetRules (TypeId type, RuleId rule);

/*!
@param type the name of a class
@param rule a RuleId value

This method is deprecated, use Application::GetRules() instead.

@return the set of rules correponding to the RuleId value for this class.
*/
	static const std::set<TypeId>& GetRules (const std::string& type, RuleId rule);

/*!
@param Id the TypeId of a class
@param Label the string to display in a contextual menu

Used to give a label for contextual menus used when the creation of an instance of
the class seems possible.

This method is deprecated, use Application::SetCreationLabel() instead.
*/
	static void SetCreationLabel (TypeId Id, std::string Label);

/*!
@param Id the TypeId of a class

This method is deprecated, use Application::GetCreationLabel() instead.

@return the string defined by SetCreationLabel.
*/
	static const std::string& GetCreationLabel (TypeId Id);

/*!
@param TypeName the name of a class

This method is deprecated, use Application::GetCreationLabel() instead.

@return the string defined by SetCreationLabel.
*/
	static const std::string& GetCreationLabel (const std::string& TypeName);

/*!
@return a new SignalId.
*/
	static SignalId CreateNewSignalId ();

protected:
/*!
@return the gcu::Dialog related to the object properties or NULL if none exists.
*/
	virtual Dialog *BuildPropertiesDialog ();

private:
	Object* RealGetDescendant (const gchar* Id) const;

private:
	char* m_Id;
	TypeId m_Type;
	Object *m_Parent;
	std::map<std::string, Object*> m_Children; //string is Id of object, so each object must have an Id
	std::set<Object*> m_Links; //objects linked to this but outside of the hierarchy
	TypeDesc const *m_TypeDesc;

private:
/*!
Set to true while loading to avoid signal propagation.
*/
	int m_Locked;

/*!\fn GetDirty()
@return true if the document has changed since it was opened or last saved,
false otherwise.
*/
GCU_RO_PROP (bool, Dirty);
};

}
#endif //GCU_OBJECT_H