Index: trunk/nv/common.hh
===================================================================
--- trunk/nv/common.hh	(revision 63)
+++ trunk/nv/common.hh	(revision 64)
@@ -10,4 +10,6 @@
 #include <typeinfo>
 #include <cstddef>
+#include <cassert>
+#include <nv/logging.hh>
 
 // NV Library version
@@ -112,6 +114,12 @@
 #endif
 
-#include <cassert>
+#define NV_STRINGIZE_DETAIL(x) #x
+#define NV_STRINGIZE(x) NV_STRINGIZE_DETAIL(x)
+
 #define NV_ASSERT(cond, msg) assert( (cond) && msg )
+#define NV_THROW(eobj, ...) { \
+	NV_LOG( LOG_ERROR, __FILE__ " line " NV_STRINGIZE(__LINE__) " - exception thrown - " #eobj ); \
+  throw eobj( __VA_ARGS__ ); \
+} 
 
 #if NV_COMPILER == NV_MSVC 
@@ -122,4 +130,12 @@
 {
 	class object;
+	class root;
+	class type_database;
+	class uid_store;
+
+	namespace lua
+	{
+		class state;
+	}
 
 	// Typedefs for fixed size types.
@@ -164,5 +180,5 @@
 #if NV_DEBUG
 	T* p = dynamic_cast<T*>(x);
-	if (p == 0) throw std::bad_cast();
+	if (p == 0) THROW( std::bad_cast, () );
 	return p;
 #else
Index: trunk/nv/interface/program.hh
===================================================================
--- trunk/nv/interface/program.hh	(revision 63)
+++ trunk/nv/interface/program.hh	(revision 64)
@@ -127,5 +127,5 @@
 			}
 			NV_LOG( LOG_ERROR, "Attribute '" << name << "' not found in program!" );
-			throw runtime_error( "Attribute '"+name+"' not found!" );
+			NV_THROW( runtime_error, ( "Attribute '"+name+"' not found!" ) );
 		}
 
@@ -148,5 +148,5 @@
 			}
 			NV_LOG( LOG_ERROR, "Uniform '" << name << "' not found in program!" );
-			throw runtime_error( "Uniform '"+name+"' not found!" );
+			NV_THROW( runtime_error, ( "Uniform '"+name+"' not found!" ) );
 		}
 
Index: trunk/nv/logging.hh
===================================================================
--- trunk/nv/logging.hh	(revision 63)
+++ trunk/nv/logging.hh	(revision 64)
@@ -14,5 +14,4 @@
 #define NV_LOGGING_HH
 
-#include <nv/common.hh>
 #include <nv/singleton.hh>
 #include <sstream>
Index: trunk/nv/object.hh
===================================================================
--- trunk/nv/object.hh	(revision 63)
+++ trunk/nv/object.hh	(revision 64)
@@ -12,6 +12,4 @@
 namespace nv
 {
-	class type_database;
-
 	/**
 	 * Implements a object tree-like structure.
@@ -36,5 +34,5 @@
 		 * Object constructor
 		 */
-		object( string aid, uid auid );
+		object( root* aroot, const string& aid, uid auid );
 
 		/**
@@ -154,4 +152,5 @@
 
 	protected:
+		root*   m_root;        ///< pointer to root
 		string  m_id;          ///< id type of the object
 		string  m_name;        ///< name of the object
Index: trunk/nv/root.hh
===================================================================
--- trunk/nv/root.hh	(revision 64)
+++ trunk/nv/root.hh	(revision 64)
@@ -0,0 +1,32 @@
+// Copyright (C) 2012 Kornel Kisielewicz
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+#ifndef NV_ROOT_HH
+#define NV_ROOT_HH
+
+#include <nv/common.hh>
+#include <nv/object.hh>
+#include <nv/string.hh>
+#include <list>
+
+namespace nv
+{
+	/**
+	 * Implements the root of a object tree-like structure.
+	 */
+	class root : public object
+	{
+	public:
+		type_database* get_type_database() const { return m_type_database; }
+		lua::state*    get_lua_state()     const { return m_lua_state; }
+		uid_store*     get_uid_store()     const { return m_uid_store; }
+	protected:
+		type_database* m_type_database;
+		lua::state*    m_lua_state;
+		uid_store*     m_uid_store; 
+	};
+
+} // namespace nv
+
+#endif // NV_ROOT_HH
Index: trunk/nv/string.hh
===================================================================
--- trunk/nv/string.hh	(revision 63)
+++ trunk/nv/string.hh	(revision 64)
@@ -16,60 +16,60 @@
 	using std::string;
 
-    /**
-     * Utility function for converting any value to string.
-     *
-     * @param value value to be converted, needs to have << operator
-     *        to stream
-     * @throw ore::runtime_error Throws ore::runtime_error on conversion fail
-     * @return value converted to string
-     */
-    template < class T >
-    string to_string( const T& value )
-    {
-      std::stringstream stream;
-      stream << value;
+	/**
+	* Utility function for converting any value to string.
+	*
+	* @param value value to be converted, needs to have << operator
+	*        to stream
+	* @throw runtime_error Throws runtime_error on conversion fail
+	* @return value converted to string
+	*/
+	template < class T >
+	string to_string( const T& value )
+	{
+		std::stringstream stream;
+		stream << value;
 
-      if ( stream.fail() )
-      {
-        throw runtime_error( "bad cast" );
-      }
+		if ( stream.fail() )
+		{
+			NV_THROW( runtime_error, "bad cast" );
+		}
 
-      return stream.str();
-    }
+		return stream.str();
+	}
 
-    /**
-     * Override function for special treatment of strings. Returns the
-     * value passed.
-     */
-    inline string to_string( const string& value)
-    {
-        return value;
-    }
+	/**
+	* Override function for special treatment of strings. Returns the
+	* value passed.
+	*/
+	inline string to_string( const string& value)
+	{
+		return value;
+	}
 
-    /**
-     * Utility function for converting a string to the given type
-     *
-     * @param vin the string representing the value
-     * @param vout the value to be read. Must be streamable with >>
-     * @throw ore::runtime_error Throws ore::runtime_error on conversion fail
-     */
-    template < class T >
-    void from_string( const string& vin, T& vout )
-    {
-      std::istringstream value( vin );
-      value >> vout;
+	/**
+	* Utility function for converting a string to the given type
+	*
+	* @param vin the string representing the value
+	* @param vout the value to be read. Must be streamable with >>
+	* @throw runtime_error Throws runtime_error on conversion fail
+	*/
+	template < class T >
+	void from_string( const string& vin, T& vout )
+	{
+		std::istringstream value( vin );
+		value >> vout;
 
-      if ( value.fail() )
-      {
-        throw runtime_error( "bad cast" );
-      }
-    }
+		if ( value.fail() )
+		{
+			NV_THROW( runtime_error, "bad cast" );
+		}
+	}
 
-    /**
-     * Utility function for converting a string to the given type
-     *
-     * @param vin the string representing the value
-     * @throw ore::runtime_error Throws ore::runtime_error on conversion fail
-     */
+	/**
+	* Utility function for converting a string to the given type
+	*
+	* @param vin the string representing the value
+	* @throw runtime_error Throws runtime_error on conversion fail
+	*/
 	template < class T >
 	T string_cast( const string& vin )
@@ -81,5 +81,5 @@
 		if ( value.fail() )
 		{
-			throw runtime_error( "bad cast" );
+			NV_THROW( runtime_error, "bad cast" );
 		}
 		return vout;
@@ -87,31 +87,31 @@
 
 
-    /**
-     * Override function for special treatment of strings. Returns the
-     * value passed.
-     */
-    inline void from_string( const string& vin, string& vout )
+	/**
+	* Override function for special treatment of strings. Returns the
+	* value passed.
+	*/
+	inline void from_string( const string& vin, string& vout )
 	{
-      vout = vin;
-    }
+		vout = vin;
+	}
 
 	/**
-     * Override function for special treatment of strings. Returns the
-     * value passed.
-     */
+	* Override function for special treatment of strings. Returns the
+	* value passed.
+	*/
 	template <>
-    inline std::string string_cast( const string& vin )
+	inline std::string string_cast( const string& vin )
 	{
 		return vin;
-    }
+	}
 
 
 	/**
-	 * Simple function for slurping a file into a string.
-	 */
+	* Simple function for slurping a file into a string.
+	*/
 	inline std::string slurp( const std::string& filename )
 	{
 		std::ifstream input(filename);
-		if ( !input.is_open() ) throw std::runtime_error("File "+filename+" not found!");
+		if ( !input.is_open() ) NV_THROW( std::runtime_error, "File "+filename+" not found!");
 		std::stringstream sstr;
 		while(input >> sstr.rdbuf());
Index: trunk/src/gl/gl_context.cc
===================================================================
--- trunk/src/gl/gl_context.cc	(revision 63)
+++ trunk/src/gl/gl_context.cc	(revision 64)
@@ -49,5 +49,5 @@
 	if ( viewport.z < 0 || viewport.w < 0 )
 	{
-		throw new logic_error("viewport width and height must be greater than zero!");
+		NV_THROW( logic_error, "viewport width and height must be greater than zero!");
 	}
 
@@ -126,5 +126,5 @@
 	if ( scissor.dim.x < 0 || scissor.dim.y < 0 )
 	{
-		throw new logic_error("scissor_test.rect width and height must be greater than zero!");
+		NV_THROW( logic_error, "scissor_test.rect width and height must be greater than zero!" );
 	}
 
@@ -174,9 +174,9 @@
 	if ( range.near < 0.0 || range.near > 1.0 )
 	{
-		throw new logic_error("render_state.depth_range.near must be between zero and one!");
+		NV_THROW( logic_error, "render_state.depth_range.near must be between zero and one!");
 	}
 	if ( range.far < 0.0 || range.far > 1.0 )
 	{
-		throw new logic_error("render_state.depth_range.far must be between zero and one!");
+		NV_THROW( logic_error, "render_state.depth_range.far must be between zero and one!");
 	}
 
Index: trunk/src/gl/texture_font.cc
===================================================================
--- trunk/src/gl/texture_font.cc	(revision 63)
+++ trunk/src/gl/texture_font.cc	(revision 64)
@@ -44,11 +44,11 @@
 	 
 	error = FT_Init_FreeType( (FT_Library*)(&m_rlibrary) );
-	if ( error ) throw std::runtime_error( "FT_Error" );
+	if ( error ) NV_THROW( std::runtime_error, "FT_Error" );
 
 	error = FT_New_Face( (FT_Library)(m_rlibrary), filename, 0, (FT_Face*)(&m_rface) );
-	if ( error ) throw std::runtime_error( "FT_Error" );
+	if ( error ) NV_THROW( std::runtime_error, "FT_Error" );
 
 	error = FT_Set_Char_Size( (FT_Face)(m_rface), (int)(size*64), 0, 72*64, 72 ); 
-	if ( error ) throw std::runtime_error( "FT_Error" );
+	if ( error ) NV_THROW( std::runtime_error, "FT_Error" );
 
     FT_Set_Transform( (FT_Face)(m_rface), &matrix, NULL );
@@ -106,5 +106,5 @@
 			error_msg << "FT_Error while loading glyphs, error: "
 				<< error << " code: " << c; 
-			throw std::runtime_error( error_msg.str().c_str() );
+			NV_THROW( std::runtime_error, error_msg.str().c_str() );
 		}
 
@@ -124,5 +124,5 @@
 				<< "r.pos.x: " << r.pos.x << " code: "
 				<< c; 
-			throw std::runtime_error( error_msg.str().c_str() );
+			NV_THROW( std::runtime_error, error_msg.str().c_str() );
 		}
 		r.size.x -= 1;
Index: trunk/src/library.cc
===================================================================
--- trunk/src/library.cc	(revision 63)
+++ trunk/src/library.cc	(revision 64)
@@ -75,5 +75,5 @@
     if ( m_handle == NULL )
     {
-        throw library_error( "Can't load library!", name );
+        NV_THROW( library_error, "Can't load library!", name );
     }
     NV_LOG( LOG_NOTICE, "library : '" + name + "' loaded." );
@@ -85,5 +85,5 @@
     if ( !result )
     {
-        throw library_error( "Can't find symbol " + symbol + "!", m_name );
+        NV_THROW( library_error, "Can't find symbol " + symbol + "!", m_name );
     }
 	return result;
Index: trunk/src/logger.cc
===================================================================
--- trunk/src/logger.cc	(revision 63)
+++ trunk/src/logger.cc	(revision 64)
@@ -5,4 +5,5 @@
 #include "nv/logger.hh"
 
+#include "nv/common.hh"
 #include <iostream>
 #include <utility>
@@ -208,5 +209,5 @@
 	{
 		// throw if not open
-		throw runtime_error( "Could not open file \""+file_name+"\" for logging!" );
+		NV_THROW( runtime_error, "Could not open file \""+file_name+"\" for logging!" );
 	}
 
Index: trunk/src/object.cc
===================================================================
--- trunk/src/object.cc	(revision 63)
+++ trunk/src/object.cc	(revision 64)
@@ -7,4 +7,5 @@
 #include "nv/object.hh"
 
+#include "nv/root.hh"
 #include "nv/types.hh"
 
@@ -12,5 +13,5 @@
 
 object::object()
-	: m_id(), m_name(), m_uid(0), m_lua_index(-2), m_parent( nullptr ), m_children(), m_child_count(0)
+	: m_root( nullptr ), m_id(), m_name(), m_uid(0), m_lua_index(-2), m_parent( nullptr ), m_children(), m_child_count(0)
 {
 //	m_uid = uid_store::get_free_uid();
@@ -18,6 +19,6 @@
 }
 
-object::object( string aid, uid auid )
-	: m_id(aid), m_name(), m_uid( auid ), m_lua_index(-2), m_parent( nullptr ), m_children(), m_child_count(0)
+object::object( root* aroot, const string& aid, uid auid )
+	: m_root( aroot ), m_id(aid), m_name(), m_uid( auid ), m_lua_index(-2), m_parent( nullptr ), m_children(), m_child_count(0)
 {
 	//	uid_store::register_object( this, auid );
