2009-12-04 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / src / namescope.h
blobb6453b60130090da4acf894fd23dea576d2719cb
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * namescope.h
5 * Copyright 2007 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
8 *
9 */
11 #ifndef __MOON_NAMESCOPE_H__
12 #define __MOON_NAMESCOPE_H__
14 #include <glib.h>
15 #include "dependencyobject.h"
16 #include "error.h"
17 #include "list.h"
19 /* @Namespace=None */
20 /* @ManagedDependencyProperties=None */
21 /* @ManagedEvents=None */
22 class NameScope : public DependencyObject {
23 GHashTable *names;
24 bool is_locked;
25 bool temporary;
27 static void ObjectDestroyedEvent (EventObject *sender, EventArgs *args, gpointer closure);
28 static gboolean remove_handler (gpointer key, gpointer value, gpointer data);
29 static void merge_name (gpointer key, gpointer value, gpointer user_data);
31 protected:
32 virtual ~NameScope ();
34 virtual void CloneCore (Types *types, DependencyObject *fromObj);
36 public:
37 /* @PropertyType=NameScope,Attached,GenerateAccessors */
38 const static int NameScopeProperty;
40 /* @GenerateCBinding*/
41 NameScope ();
43 virtual void Dispose ();
45 void RegisterName (const char *name, DependencyObject *object);
46 void UnregisterName (const char *name);
48 DependencyObject *FindName (const char *name);
50 bool GetIsLocked () { return is_locked; }
51 void Lock () { is_locked = true; }
53 void SetTemporary (bool flag) { temporary = flag; }
54 bool GetTemporary () { return temporary; }
56 void MergeTemporaryScope (NameScope *scope, MoonError *error);
58 static NameScope *GetNameScope (DependencyObject *obj);
59 static void SetNameScope (DependencyObject *obj, NameScope *scope);
61 void Dump();
63 GHashTable *GetNames () { return names; }
66 #endif /* __MOON_NAMESCOPE_H__ */