Skip to content

Commit

Permalink
added frames & graphs interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
andreapasquale94 committed Nov 11, 2023
1 parent b383f50 commit 1797e3f
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 28 deletions.
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name = "JSMDInterfaces"
uuid = "6b30ee2f-618e-4a15-bf4e-7df7b496e609"
authors = ["JSMD Team"]
version = "1.3.1"
version = "1.4.0"

[deps]
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
SMDGraphs = "b792745b-7241-45be-ba96-70eb67e8468f"

[compat]
julia = "1"
Expand Down
2 changes: 1 addition & 1 deletion src/Errors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ macro custom_error(expr)
return esc(
quote
"""
$($(name))
$($(ename))
A type representing $($(descr)).
"""
Expand Down
4 changes: 2 additions & 2 deletions src/FilesIO.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module FilesIO

using JSMDInterfaces.Interface: @interface
using SMDGraphs: AbstractGraphNode
using JSMDInterfaces.Graph: AbstractJSMDGraphNode

export load, filepath, filepaths

Expand Down Expand Up @@ -66,7 +66,7 @@ end

# JSMD interface

abstract type AbstractArchiveNode <: AbstractGraphNode end
abstract type AbstractArchiveNode <: AbstractJSMDGraphNode end

"""
function load(::AbstractArchiveNode)
Expand Down
31 changes: 10 additions & 21 deletions src/Models/frame.jl → src/Frames.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
export AbstractFrameGraphModel, AbstractFrameGraphAxisNode, AbstractFrameGraphPointNode,
vector3, vector6, vector9, vector12,
rotation3, rotation6, rotation9, rotation12
module Frames

using Graphs: AbstractGraph
using JSMDInterfaces.Interface: @interface

export AbstractFrameGraphModel,
vector3, vector6, vector9, vector12,
rotation3, rotation6, rotation9, rotation12

"""
AbstractFrameGraphModel
Expand All @@ -12,22 +15,6 @@ Subtype it to create a new frames graph compatible with the ecosystem.
"""
abstract type AbstractFrameGraphModel{T} <: AbstractGraph{T} end

"""
AbstractFrameGraphPointNode
Abstract type for frame graphs points nodes.
Subtype it to create a point node type for a frame graph.
"""
abstract type AbstractFrameGraphPointNode <: AbstractGraphNode end

"""
AbstractFrameGraphAxisNode
Abstract type for frame graphs axes nodes.
Subtype it to create an axis node type for a frame graph.
"""
abstract type AbstractFrameGraphAxisNode <: AbstractGraphNode end

# ----
# JSMD interface

Expand All @@ -46,7 +33,7 @@ This function serves as an interface for constructing a position vector using a
!!! warning
Concrete implementations of `AbstractFrameGraphModel` must provide this function!
"""
@interface function vector3(::F, ::Int, ::Int, ::Int, ::T) where {T, F <: AbstractFrameGraphModel} end
@interface function vector3(::AbstractFrameGraphModel, ::Int, ::Int, ::Int, ::Number) end

"""
vector6(model::F, from::Int, to::Int, axis::Int, time::T) where {T, F <: AbstractFrameGraphModel}
Expand Down Expand Up @@ -167,4 +154,6 @@ derivative between two axes within a frame graph model.
!!! warning
Concrete implementations of `AbstractFrameGraphModel` must provide this function!
"""
@interface function rotation12(::F, ::Int, ::Int, ::T) where {T, F <: AbstractFrameGraphModel} end
@interface function rotation12(::F, ::Int, ::Int, ::T) where {T, F <: AbstractFrameGraphModel} end

end
41 changes: 41 additions & 0 deletions src/Graph.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module Graph

using JSMDInterfaces.Interface: @interface

using Graphs

import Graphs: has_vertex, has_edge, edges, edgetype, inneighbors, ne, nv, outneighbors, vertices, is_directed

abstract type AbstractJSMDGraph{T} <: AbstractGraph{T} end

abstract type AbstractJSMDGraphNode end

# Graphs interface

@interface function Graphs.has_vertex(::AbstractJSMDGraph, ::Int) end

@interface function Graphs.has_edge(::AbstractJSMDGraph, ::Int, ::Int) end

@interface function Graphs.edges(::AbstractJSMDGraph) end

@interface function Graphs.edgetype(::AbstractJSMDGraph) end

@interface function Graphs.inneighbors(::AbstractJSMDGraph, ::Int) end

@interface function Graphs.ne(::AbstractJSMDGraph) end

@interface function Graphs.nv(::AbstractJSMDGraph) end

@interface function Graphs.outneighbors(::AbstractJSMDGraph, ::Int) end

@interface function Graphs.vertices(::AbstractJSMDGraph) end

@interface function Graphs.is_directed(::AbstractJSMDGraph) end

# JSMD interface

@interface function add_vertex!(::AbstractJSMDGraph, ::N) where {N<:AbstractJSMDGraph} end

@interface function add_edge!(::AbstractJSMDGraph, ::Int, ::Int, ::Int) end

end
2 changes: 2 additions & 0 deletions src/JSMDInterfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ module JSMDInterfaces

include("Errors.jl")
include("Interface.jl")
include("Graph.jl")
include("FilesIO.jl")

include("Frames.jl")
include("Math.jl")
include("Ephemeris.jl")

Expand Down
2 changes: 0 additions & 2 deletions src/Models/Models.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
module Models

using JSMDInterfaces.Errors
using SMDGraphs: AbstractGraphNode
using JSMDInterfaces.Interface: @interface
using JSMDInterfaces.FilesIO: AbstractArchiveNode

include("abstract.jl")
include("acceleration.jl")
include("frame.jl")

end

0 comments on commit 1797e3f

Please sign in to comment.