function bareTopic(id){
	this.id=id||''
	this.instanceOf='tt-urtype'

	// ====== Interface =========
}
//------------------------------------------------
function scopedObject(){
    /*A scoped object contains a list of scopes*/
	this.scopes=new Array()

	// ====== Interface =========
	this.getScopes=_getscopes
	this.addScope=_addscope
	this.hasScope=_has_scope_or
	this.hasScopeOr=_has_scope_or
	this.hasScopeAnd=_has_scope_and
	
	function _getscopes(){
		return this.scopes
	}
	function _addscope(scope){
		if (!scope) return
		this.scopes[this.scopes.length]=scope		
	}
	
	/* Return true if any scope of this object
	   matches any one of the scopes in the filter,
	   which is a list of scopes topic ids.
	*/
	function _has_scope_or(filters){
		if (!filters||!filters.length){return true}
		if (filters[0]=='st-unconstrained'){
			return true
		}
		var f,filter
		var Scope
		
		for (f in filters){
			filter=filters[f]
			for (s in this.scopes){
				Scope=this.scopes[s]
				if (Scope.topic==filter){
					return true	
				}
			}
		}
		return false
	}

	/* Return true if this object has a subset of scopes that
	   matches all of the scopes in the filter,
	   which is a list of scopes topic ids.
	*/
	function _has_scope_and(filters){
		if (!filters||!filters.length){return true}
		if (filters[0]=='st-unconstrained'){
			return true
		}
		var f,filter
		var Scope
		var has_this_scope
		
		for (f in filters){
			has_this_scope=false
			filter=filters[f]
			for (s in this.scopes){
				Scope=this.scopes[s]
				if (Scope.topic==filter){
					has_this_scope=true
					break
				}
			}
			if (!has_this_scope){return false}
		}
		return has_this_scope
	}
}


//------------------------------------------------

function scopedTopic(id){
	this.parent=bareTopic
	this.parent(id)
	// Simulate multiple inheritance
	this.parent2=scopedObject  
	this.parent2()
}
//------------------------------------------------
