-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement prototypical ModelWarperV3 (step-by-step design) tab
- Loading branch information
1 parent
c143cd0
commit 7a08854
Showing
24 changed files
with
1,458 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
#include <oscar/Utils/UID.h> | ||
|
||
#include <stdexcept> | ||
|
||
namespace OpenSim { class Component; } | ||
|
||
namespace osc | ||
{ | ||
class IComponentAccessor { | ||
protected: | ||
IComponentAccessor() = default; | ||
IComponentAccessor(const IComponentAccessor&) = default; | ||
IComponentAccessor(IComponentAccessor&&) noexcept = default; | ||
IComponentAccessor& operator=(const IComponentAccessor&) = default; | ||
IComponentAccessor& operator=(IComponentAccessor&&) noexcept = default; | ||
|
||
friend bool operator==(const IComponentAccessor&, const IComponentAccessor&) = default; | ||
public: | ||
virtual ~IComponentAccessor() noexcept = default; | ||
|
||
const OpenSim::Component& getComponent() const { return implGetComponent(); } | ||
operator const OpenSim::Component& () const { return getComponent(); } | ||
|
||
bool isReadonly() const { return not implCanUpdComponent(); } | ||
bool canUpdComponent() const { return implCanUpdComponent(); } | ||
OpenSim::Component& updComponent() { return implUpdComponent(); } | ||
|
||
private: | ||
// Implementors should return a const reference to an initialized (finalized properties, etc.) component | ||
virtual const OpenSim::Component& implGetComponent() const = 0; | ||
|
||
// Implementors may return whether the component contained by the concrete `IComponentAccessor` implementation | ||
// can be modified in-place. | ||
// | ||
// If the response can be `true`, implementors must also override `implUpdComponent` accordingly. | ||
virtual bool implCanUpdComponent() const { return false; } | ||
|
||
// Implementors may return a mutable reference to the contained component. It is up to the caller | ||
// of `updComponent` to ensure that the component is still valid + initialized after modification. | ||
// | ||
// If this is implemented, implementors should override `implCanUpdComponent` accordingly. | ||
virtual OpenSim::Component& implUpdComponent() | ||
{ | ||
throw std::runtime_error{"component updating not implemented for this IComponentAccessor"}; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "IModelStatePair.h" | ||
|
||
#include <OpenSim/Common/Component.h> | ||
#include <OpenSim/Simulation/Model/Model.h> | ||
|
||
const OpenSim::Component& osc::IModelStatePair::implGetComponent() const { return implGetModel(); } | ||
OpenSim::Component& osc::IModelStatePair::implUpdComponent() { return implUpdModel(); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/OpenSimCreator/Documents/Model/IVersionedComponentAccessor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <OpenSimCreator/Documents/Model/IComponentAccessor.h> | ||
|
||
namespace osc | ||
{ | ||
class IVersionedComponentAccessor : public IComponentAccessor { | ||
public: | ||
UID getComponentVersion() const { return implGetComponentVersion(); } | ||
void setComponentVersion(UID id) { implSetComponentVersion(id); } | ||
|
||
private: | ||
// Implementors may return a `UID` that uniquely identifies the current version of the component. | ||
virtual UID implGetComponentVersion() const | ||
{ | ||
// assume the version always changes, unless the concrete implementation | ||
// provides a way of knowing when it doesn't | ||
return UID{}; | ||
} | ||
|
||
// Implementors may use this to manually set the version of the component (sometimes useful for caching) | ||
virtual void implSetComponentVersion(UID) {} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.