Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/did/+did/+datastructures/emptystruct.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
% end;
%
% See also: VAR2STRUCT
arguments (Repeating)
varargin
end

if isempty(varargin)
s = struct([]);
Expand All @@ -37,5 +40,5 @@
end
s = s([]);
%}
s = cell2struct(cell(numel(fields),0), fields');
s = cell2struct(cell(numel(fields),0), fields(:));
end
13 changes: 10 additions & 3 deletions src/did/+did/+file/fileobj.m
Original file line number Diff line number Diff line change
Expand Up @@ -329,20 +329,27 @@ function frewind(fileobj_obj)
end
end % fscanf()

function count = fprintf(fileobj_obj, varargin)
function count = fprintf(fileobj_obj, format, varargin)
% FPRINTF - print data to a FILEOBJ_OBJ
%
% [COUNT] = FPRINTF(FID,FORMAT,A, ...)
%
% Call FPRINTF (see FPRINTF for inputs) for the file associated with
% FILEOBJ_OBJ.
arguments
fileobj_obj
format (1,:) char
end
arguments (Repeating)
varargin
end

if strcmpi(fileobj_obj.permission,'r')
error('DID:File:Fileobj','Cannot use fprintf() method with read-only file');
end
count = 0;
if fileobj_obj.fid >= 0
count = fprintf(fileobj_obj.fid,varargin{:});
count = fprintf(fileobj_obj.fid,format,varargin{:});
end
end % fprintf()

Expand Down Expand Up @@ -370,4 +377,4 @@ function delete(fileobj_obj)
end % delete()
end % methods

end % classdef
end % classdef
11 changes: 9 additions & 2 deletions src/did/+did/+file/readonly_fileobj.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@
% See also: FILEOBJ

methods
function fileobj_obj = readonly_fileobj(varargin)
function fileobj_obj = readonly_fileobj(options)
% READONLY_FILEOBJ - create a new read-only binary file object
%
% FILEOBJ_OBJ = READONLY_FILEOBJ(...)
%
% Creates an empty FILEOBJ object. If FILENAME is provided,
% then the filename is stored.
arguments
options.machineformat (1,1) string {did.file.mustBeValidMachineFormat} = 'n'; % native machine format
options.permission (1,1) string {did.file.mustBeValidPermission} = "r"
options.fid (1,1) int64 = -1
options.fullpathfilename = '';
end

% Call the super-class constructor
fileobj_obj@did.file.fileobj(varargin{:});
super_options = namedargs2cell(options);
fileobj_obj@did.file.fileobj(super_options{:});

% Ensure that the default 'r' permission was not modified
if ~strcmpi(fileobj_obj.permission(1),'r')
Expand Down
18 changes: 13 additions & 5 deletions src/did/+did/+fun/findalldependencies.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [d] = findalldependencies(DB, visited, varargin)
function [d] = findalldependencies(DB, visited, docs)
% FINDALLDEPENDENCIES- find documents that have dependencies on documents that do not exist
%
% [D] = FINDALLDEPENDENCIES(DB, VISITED, DOC1, DOC2, ...)
Expand All @@ -10,19 +10,27 @@
%
% D is always a cell array of DID.DOCUMENT objects (perhaps empty, {}).
%
arguments
DB did.database
visited cell
end
arguments (Repeating)
docs
end


d = {};

if isempty(visited)
visited = {};
end

for i=1:numel(varargin)
visited = cat(1,visited,{varargin{i}.id()});
for i=1:numel(docs)
visited = cat(1,visited,{docs{i}.id()});
end

for i=1:numel(varargin)
q_v = ndi_query('','depends_on','*',varargin{i}.id());
for i=1:numel(docs)
q_v = ndi_query('','depends_on','*',docs{i}.id());
bb = DB.database_search(q_v);

for j=1:numel(bb)
Expand Down
10 changes: 8 additions & 2 deletions src/did/+did/+fun/finddocs_missing_dependencies.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function d = finddocs_missing_dependencies(DB, varargin)
function d = finddocs_missing_dependencies(DB, names)
% FINDDOCS_MISSING_DEPENDENCIES - find documents that have dependencies on documents that do not exist
%
% D = FINDDOCS_MISSING_DEPENDENCIES(DB)
Expand All @@ -14,6 +14,12 @@
% works similarly except that it only examines variables with depends_on
% fields with names NAME1, NAME2, etc.
%
arguments
DB did.database
end
arguments (Repeating)
names
end

documents_observed = {}; % keep track of what we have seen so we don't have to search multiple times

Expand All @@ -30,7 +36,7 @@
for i=1:numel(d)
for j=1:numel(d{i}.document_properties.depends_on)
if nargin>1
match = any(strcmpi(d{i}.document_properties.depends_on(j).name,varargin));
match = any(strcmpi(d{i}.document_properties.depends_on(j).name,names));
else
match = 1;
end
Expand Down
19 changes: 12 additions & 7 deletions src/did/+did/+fun/plotinteractivedocgraph.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function plotinteractivedocgraph(varargin) %(docs, G, mdigraph, nodes)
function plotinteractivedocgraph(docs, G, mdigraph, nodes, layout)
% PLOTINTERACTIVEDOCGRAPH(DOCS, G, MDIGRAPH, NODES, LAYOUT)
%
% Given a cell array of NDI_DOCUMENTs DOCS, a connectivity matrix
Expand All @@ -23,6 +23,13 @@ function plotinteractivedocgraph(varargin) %(docs, G, mdigraph, nodes)
% [G,nodes,mdigraph] = did.fun.docs2graph(docs);
% did.fun.plotinteractivedocgraph(docs,G,mdigraph,nodes,'layered');
%
arguments
docs cell
G
mdigraph
nodes
layout char
end

if nargin==0

Expand Down Expand Up @@ -53,15 +60,13 @@ function plotinteractivedocgraph(varargin) %(docs, G, mdigraph, nodes)
return;
end

layout = varargin{5};

f = figure;

userData = struct();
userData.docs = varargin{1};
userData.G = varargin{2};
userData.mdigraph = varargin{3};
userData.nodes = varargin{4};
userData.docs = docs;
userData.G = G;
userData.mdigraph = mdigraph;
userData.nodes = nodes;

set(f,'userdata',userData);

Expand Down
14 changes: 10 additions & 4 deletions src/did/+did/+implementations/matlabdumbjsondb.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

methods

function did_matlabdumbjsondb_obj = matlabdumbjsondb(varargin)
function did_matlabdumbjsondb_obj = matlabdumbjsondb(command, path, options)
% DID_MATLABDUMBJSONDB make a new MATLABDUMBJSONDB object
%
% DID_MATLABDUMBJSONDB_OBJ = DID_MATLABDUMBJSONDB(COMMAND, PATHNAME)
Expand All @@ -18,13 +18,19 @@
% should be stored on disk.
%
% See also: DUMBJSONDB, DUMBJSONDB/DUMBJSONDB
arguments
command char
path char
options.dirname char = 'dumbjsondb'
options.unique_object_id_field char = 'base.id'
end
connection = '';
if nargin>1
connection = varargin{2};
connection = path;
end
did_matlabdumbjsondb_obj = did_matlabdumbjsondb_obj@did.database(connection);
did_matlabdumbjsondb_obj.db = did.file.dumbjsondb(varargin{1:end},...
'dirname','dumbjsondb','unique_object_id_field','base.id');
did_matlabdumbjsondb_obj.db = did.file.dumbjsondb(command, path,...
'dirname',options.dirname,'unique_object_id_field',options.unique_object_id_field);
end % did_matlabdumbjsondb()
end

Expand Down
8 changes: 6 additions & 2 deletions src/did/+did/+implementations/sqldb.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
end

methods % constructor
function sqldb_obj = sqldb(varargin)
function sqldb_obj = sqldb(command, path)
% SQLDB create a new SQLDB object
%
% SQLDB_OBJ = SQLDB(...)
Expand All @@ -17,9 +17,13 @@
% the full pathname of where the files should be stored on disk.
%
% See also: DUMBJSONDB, SQLITEDB, POSTGRESDB
arguments
command char
path char
end
connection = '';
if nargin>1
connection = varargin{2};
connection = path;
end
sqldb_obj = sqldb_obj@did.database(connection);
end % sqldb()
Expand Down
Loading
Loading