Home > functions > internal > dsGetNamespaces.m

dsGetNamespaces

PURPOSE ^

Purpose: retrieve namespaces for all objects in specification

SYNOPSIS ^

function [name_,name__] = dsGetNamespaces(spec)

DESCRIPTION ^

 Purpose: retrieve namespaces for all objects in specification
 Outputs:
   name_: object names separated by single underscore
   name__: object names separated by double underscores

 See also: dsPropagateNamespaces

 Author: Jason Sherfey, PhD <jssherfey@gmail.com>
 Copyright (C) 2016 Jason Sherfey, Boston University, USA

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [name_,name__] = dsGetNamespaces(spec)
0002 % Purpose: retrieve namespaces for all objects in specification
0003 % Outputs:
0004 %   name_: object names separated by single underscore
0005 %   name__: object names separated by double underscores
0006 %
0007 % See also: dsPropagateNamespaces
0008 %
0009 % Author: Jason Sherfey, PhD <jssherfey@gmail.com>
0010 % Copyright (C) 2016 Jason Sherfey, Boston University, USA
0011 
0012 
0013 if isfield(spec,'specification') % this is a model structure
0014   spec=spec.specification; % extract the specification
0015 end
0016 
0017 name_={};
0018 name__={};
0019 
0020 % population namespaces to replace
0021 for i=1:length(spec.populations)
0022   name_{end+1}=[spec.populations(i).name '_'];
0023   name__{end+1}=[spec.populations(i).name '_'];
0024   for j=1:length(spec.populations(i).mechanisms)
0025     name_{end+1}=[spec.populations(i).name '_' spec.populations(i).mechanisms(j).name '_'];
0026     name__{end+1}=[spec.populations(i).name '__' spec.populations(i).mechanisms(j).name '_'];
0027   end
0028 end
0029 
0030 % connection namespaces to replace
0031 for i=1:length(spec.connections)
0032   name_{end+1}=[spec.connections(i).target '_' spec.connections(i).source '_'];
0033   name__{end+1}=[spec.connections(i).target '__' spec.connections(i).source '_'];
0034   for j=1:length(spec.connections(i).mechanisms)
0035     name_{end+1}=[spec.connections(i).target '_' spec.connections(i).source '_' spec.connections(i).mechanisms(j).name '_'];
0036     name__{end+1}=[spec.connections(i).target '__' spec.connections(i).source '__' spec.connections(i).mechanisms(j).name '_'];
0037   end
0038 end

Generated on Tue 12-Dec-2017 11:32:10 by m2html © 2005