Commit ddcc8344 authored by David Thompson's avatar David Thompson
Browse files

WIP: Add a registrar and update constructors.

All components must now provide a constructor whose
first argument is a JSON object. This will be used
for read operations.

New operations introduced:
+ Create – create an empty markup resource
+ Read – read a markup resource from a file
+ SetName – rename a markup resource or any of its components
parent fcfd9678
......@@ -22,6 +22,12 @@ public:
{
}
template<typename... Args>
AnalyticShape(const nlohmann::json* j, Args&&... args)
: smtk::markup::SpatialData(std::forward<Args>(args)...)
{
}
~AnalyticShape() override;
protected:
......
......@@ -22,6 +22,12 @@ public:
{
}
template<typename... Args>
BoundaryOperator(const nlohmann::json*, Args&&... args)
: smtk::markup::Domain(std::forward<Args>(args)...)
{
}
~BoundaryOperator() override;
protected:
......
......@@ -22,6 +22,12 @@ public:
{
}
template<typename... Args>
Box(const nlohmann::json* j, Args&&... args)
: smtk::markup::AnalyticShape(std::forward<Args>(args)...)
{
}
~Box() override;
bool setRange(const std::array<std::array<double, 3>, 2>& range);
......
......@@ -3,6 +3,9 @@ set(headers
queries/SelectionFootprint.h
)
set(operations
Create
Read
SetName
Write
)
......@@ -10,6 +13,8 @@ list(APPEND classes
Resource
DomainMap
Registrar
AssignedIds
Component
Domain
......
......@@ -22,6 +22,12 @@ public:
{
}
template<typename... Args>
Cone(const nlohmann::json* j, Args&&... args)
: smtk::markup::AnalyticShape(std::forward<Args>(args)...)
{
}
~Cone() override;
bool setEndpoints(const std::array<std::array<double, 3>, 2>& endpoints);
......
// Copyright © Kitware Inc under the [BSD-3-clause license](https://opensource.org/licenses/BSD-3-Clause).
#ifndef smtk_markup_DomainFactory_h
#define smtk_markup_DomainFactory_h
#include "smtk/markup/Component.h"
#include "smtk/common/Factory.h"
#include "smtk/common/UUID.h"
#include "nlohmann/json.hpp"
namespace smtk
{
namespace markup
{
class Resource;
using DomainFactory =
smtk::common::Factory<
smtk::markup::Domain,
// Possible constructor arguments:
// 1. Just a token (name):
smtk::string::Token,
// 2. A JSON pointer (references cause problems) and token (name)
smtk::common::factory::Inputs<
const nlohmann::json*,
smtk::string::Token
>
>;
} // namespace markup
} // namespace smtk
#endif // smtk_markup_DomainFactory_h
......@@ -22,6 +22,12 @@ public:
{
}
template<typename... Args>
ExplicitSubset(const nlohmann::json* j, Args&&... args)
: smtk::markup::Subset(std::forward<Args>(args)...)
{
}
~ExplicitSubset() override;
bool setMembers(const std::set<smtk::markup::AssignedIds::IdType>& members);
......
......@@ -27,6 +27,12 @@ public:
{
}
template<typename... Args>
Field(const nlohmann::json* j, Args&&... args)
: smtk::markup::Component(std::forward<Args>(args)...)
{
}
~Field() override;
std::string name() const;
......
......@@ -22,6 +22,12 @@ public:
{
}
template<typename... Args>
Frame(const nlohmann::json* j, Args&&... args)
: smtk::markup::SpatialData(std::forward<Args>(args)...)
{
}
~Frame() override;
bool setAxes(const std::vector<std::vector<double>>& axes);
......
......@@ -24,6 +24,12 @@ public:
{
}
template<typename... Args>
Grid(const nlohmann::json* j, Args&&... args)
: smtk::markup::DiscreteGeometry(std::forward<Args>(args)...)
{
}
~Grid() override;
bool setPoints(const std::weak_ptr<smtk::markup::AssignedIds>& points);
......
......@@ -25,6 +25,12 @@ public:
{
}
template<typename... Args>
Group(const nlohmann::json* j, Args&&... args)
: smtk::markup::Component(std::forward<Args>(args)...)
{
}
~Group() override;
......
......@@ -44,6 +44,12 @@ public:
{
}
template<typename... Args>
IdSpace(const nlohmann::json* j, Args&&... args)
: smtk::markup::Domain(std::forward<Args>(args)...)
{
}
~IdSpace() override;
const std::array<IdSpace::IdType, 2>& range() const;
......
......@@ -27,6 +27,12 @@ public:
{
}
template<typename... Args>
Image(const nlohmann::json* j, Args&&... args)
: smtk::markup::DiscreteGeometry(std::forward<Args>(args)...)
{
}
~Image() override;
bool setAxes(const std::vector<std::weak_ptr<smtk::markup::AssignedIds>>& axes);
......
......@@ -27,6 +27,12 @@ public:
{
}
template<typename... Args>
ImplicitShape(const nlohmann::json* j, Args&&... args)
: smtk::markup::AnalyticShape(std::forward<Args>(args)...)
{
}
~ImplicitShape() override;
bool setDomain(const std::weak_ptr<smtk::markup::Domain>& domain);
......
......@@ -22,6 +22,12 @@ public:
{
}
template<typename... Args>
Index(const nlohmann::json* j, Args&&... args)
: smtk::markup::Domain(std::forward<Args>(args)...)
{
}
~Index() override;
protected:
......
......@@ -23,6 +23,12 @@ public:
{
}
template<typename... Args>
Label(const nlohmann::json* j, Args&&... args)
: smtk::markup::Component(std::forward<Args>(args)...)
{
}
~Label() override;
ArcEditor<SelfType, smtk::markup::Component> subject() const;
......
......@@ -24,6 +24,12 @@ public:
{
}
template<typename... Args>
LabelMap(const nlohmann::json* j, Args&&... args)
: smtk::markup::Field(std::forward<Args>(args)...)
{
}
~LabelMap() override;
/// A set of labels that form the image of the label-map.
......
......@@ -21,6 +21,12 @@ public:
{
}
template<typename... Args>
Landmark(const nlohmann::json* j, Args&&... args)
: smtk::markup::Feature(std::forward<Args>(args)...)
{
}
~Landmark() override;
protected:
......
// Copyright © Kitware Inc under the [BSD-3-clause license](https://opensource.org/licenses/BSD-3-Clause).
#ifndef smtk_markup_NodeFactory_h
#define smtk_markup_NodeFactory_h
#include "smtk/markup/Component.h"
#include "smtk/common/Factory.h"
#include "smtk/common/UUID.h"
#include "nlohmann/json.hpp"
namespace smtk
{
namespace markup
{
class Resource;
using NodeFactory =
smtk::common::Factory<
smtk::markup::Component,
// Possible constructor arguments:
// 1. Just a resource-pointer:
std::shared_ptr<smtk::markup::Resource>,
// 2. A resource-pointer and a UUID
smtk::common::factory::Inputs<
std::shared_ptr<smtk::markup::Resource>,
smtk::common::UUID
>,
// 3. A JSON pointer (references cause problems), resource-pointer, and UUID
smtk::common::factory::Inputs<
const nlohmann::json*,
std::shared_ptr<smtk::markup::Resource>,
smtk::common::UUID
>
>;
} // namespace markup
} // namespace smtk
#endif // smtk_markup_NodeFactory_h
......@@ -26,6 +26,12 @@ public:
{
}
template<typename... Args>
Ontology(const nlohmann::json* j, Args&&... args)
: smtk::markup::Component(std::forward<Args>(args)...)
{
}
~Ontology() override;
bool setUrl(const std::string& url);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment