Skip to content

Commit

Permalink
Merge pull request #1193 from dcoeurjo/Concepts
Browse files Browse the repository at this point in the history
Merged.
  • Loading branch information
rolanddenis authored Jun 26, 2016
2 parents e1f842a + d1da721 commit fe9e169
Show file tree
Hide file tree
Showing 50 changed files with 1,011 additions and 984 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
[#1161](https://github.com/DGtal-team/DGtal/pull/1161))
- Fixing issues raised on some algorithms when changing Euclidean ring
for SpaceND and KhalimskySpaceND. (Jérémy Levallois, [#1163](https://github.com/DGtal-team/DGtal/pull/1163))
- Moving last concepts to concepts:: namespace. (David Coeurjolly,
[#1193](https://github.com/DGtal-team/DGtal/pull/1193))

- *DEC Package*
- Fixing warnings in DiscreteExteriorCalculus and DiscreteExteriorCalculusFactory.
Expand Down
121 changes: 61 additions & 60 deletions src/DGtal/base/CStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,77 +47,78 @@

namespace DGtal
{
namespace concepts
{
/////////////////////////////////////////////////////////////////////////////
// class CStack
/**
Description of \b concept '\b CStack' <p>
@ingroup Concepts
@brief Aim: This concept gathers classes that provide
a stack interface
/////////////////////////////////////////////////////////////////////////////
// class CStack
/**
Description of \b concept '\b CStack' <p>
@ingroup Concepts
@brief Aim: This concept gathers classes that provide
a stack interface
### Refinement of copy constructible and assignable
### Inner types :
- Value type of element stored in the stack
- Size type that represents the number of elements
### Refinement of copy constructible and assignable
### Notation
- \e X : A type that is a model of CStack
- \e x : object of type X
- \e v : object of type Value
### Inner types :
- Value type of element stored in the stack
- Size type that represents the number of elements
### Definitions
### Notation
- \e X : A type that is a model of CStack
- \e x : object of type X
- \e v : object of type Value
### Valid expressions and semantics
### Definitions
| Name | Expression | Type requirements | Return type | Precondition | Semantics | Post condition | Complexity |
|-------+------------+-------------------+------------------------+--------------+------------------------------------+----------------+------------|
| size | x.size() | | Size | | returns the number of elements | | O(1) |
| empty | x.empty() | | bool | | 'true' is empty, 'false' otherwise | | O(1) |
| top | x.top() | | Value& or const Value& | | returns the top element | | O(1) |
| push | x.push(v) | | void | | inserts a new element at the top | | O(1) |
| pop | x.pop() | | void | | removes the top element | | O(1) |
### Valid expressions and semantics
| Name | Expression | Type requirements | Return type | Precondition | Semantics | Post condition | Complexity |
|-------+------------+-------------------+------------------------+--------------+------------------------------------+----------------+------------|
| size | x.size() | | Size | | returns the number of elements | | O(1) |
| empty | x.empty() | | bool | | 'true' is empty, 'false' otherwise | | O(1) |
| top | x.top() | | Value& or const Value& | | returns the top element | | O(1) |
| push | x.push(v) | | void | | inserts a new element at the top | | O(1) |
| pop | x.pop() | | void | | removes the top element | | O(1) |
### Models
std::stack, BackInsertionSequenceToStackAdapter, FrontInsertionSequenceToStackAdapter are the usual models of CStack.
### Models
@tparam T the type that should be a model of CStack.
*/
template <typename T>
struct CStack : boost::CopyConstructible<T>, boost::Assignable<T>
{
// ----------------------- Concept checks ------------------------------
public:
typedef typename T::value_type Value;
typedef typename T::size_type Size;
std::stack, BackInsertionSequenceToStackAdapter, FrontInsertionSequenceToStackAdapter are the usual models of CStack.
BOOST_CONCEPT_USAGE( CStack )
{
concepts::ConceptUtils::sameType( myV, myX.top() );
myX.push( myV );
myX.pop();

// check const methods.
checkConstConstraints();
}
void checkConstConstraints() const
@tparam T the type that should be a model of CStack.
*/
template <typename T>
struct CStack : boost::CopyConstructible<T>, boost::Assignable<T>
{
concepts::ConceptUtils::sameType( myS, myX.size() );
concepts::ConceptUtils::sameType( myB, myX.empty() );
concepts::ConceptUtils::sameType( myV, myX.top() );
}
// ------------------------- Private Datas --------------------------------
private:
T myX; // do not require T to be default constructible.
Value myV;
Size myS;
bool myB;

}; // end of concept CStack

// ----------------------- Concept checks ------------------------------
public:
typedef typename T::value_type Value;
typedef typename T::size_type Size;

BOOST_CONCEPT_USAGE( CStack )
{
concepts::ConceptUtils::sameType( myV, myX.top() );
myX.push( myV );
myX.pop();

// check const methods.
checkConstConstraints();
}
void checkConstConstraints() const
{
concepts::ConceptUtils::sameType( myS, myX.size() );
concepts::ConceptUtils::sameType( myB, myX.empty() );
concepts::ConceptUtils::sameType( myV, myX.top() );
}
// ------------------------- Private Datas --------------------------------
private:
T myX; // do not require T to be default constructible.
Value myV;
Size myS;
bool myB;

}; // end of concept CStack
}//namespace concepts
} // namespace DGtal

// //
Expand Down
2 changes: 1 addition & 1 deletion src/DGtal/dec/doc/packageDECConcepts.dox
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ digraph GDEC {
node [style=filled,color=white];
label="math/linalg";

CVectorSpace [ label="CVectorSpace" URL="\ref CVectorSpace" ];
CVectorSpace [ label="CVectorSpace" URL="\ref concepts::CVectorSpace" ];
CMatrix [ label="CMatrix" URL="\ref concepts::CMatrix" ];
CStaticMatrix [ label="CStaticMatrix" URL="\ref concepts::CStaticMatrix" ];
CDynamicMatrix [ label="CDynamicMatrix" URL="\ref concepts::CDynamicMatrix" ];
Expand Down
87 changes: 44 additions & 43 deletions src/DGtal/geometry/curves/CBidirectionalSegmentComputer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,65 +47,66 @@

namespace DGtal
{

/////////////////////////////////////////////////////////////////////////////
// class CBidirectionalSegmentComputer
/**
Description of \b concept '\b CBidirectionalSegmentComputer' <p>
@ingroup Concepts
@brief Aim: Defines the concept describing a bidirectional segment computer,
ie. a model of CSegment that can extend itself in the two possible directions.
namespace concepts
{
/////////////////////////////////////////////////////////////////////////////
// class CBidirectionalSegmentComputer
/**
Description of \b concept '\b CBidirectionalSegmentComputer' <p>
@ingroup Concepts
@brief Aim: Defines the concept describing a bidirectional segment computer,
ie. a model of concepts::CSegment that can extend itself in the two possible directions.
### Refinement of CForwardSegmentComputer
### Refinement of CForwardSegmentComputer
### Associated types : the same as CForwardSegmentComputer
### Associated types : the same as concepts::CForwardSegmentComputer
### Notation
- \a X : A type that is a model of CBidirectionalSegmentComputer
- \a x : object of type X
### Notation
- \a X : A type that is a model of CBidirectionalSegmentComputer
- \a x : object of type X
### Definitions
### Definitions
### Valid expressions and
### Valid expressions and
| Name | Expression | Type requirements | Return type | Precondition | Semantics | Post condition | Complexity |
|---------------|------------|---------------------|-------------|------------------|-----------|----------------|------------|
| Extension test | x.isExtendableBack() | |bool | | check whether x can be extended to - -x.begin() or not | | |
| Extension | x.extendBack() | |bool | | check whether x can be extended to - -x.begin() or not, extend if true | | |
| Name | Expression | Type requirements | Return type | Precondition | Semantics | Post condition | Complexity |
|---------------|------------|---------------------|-------------|------------------|-----------|----------------|------------|
| Extension test | x.isExtendableBack() | |bool | | check whether x can be extended to - -x.begin() or not | | |
| Extension | x.extendBack() | |bool | | check whether x can be extended to - -x.begin() or not, extend if true | | |
### Invariants###
### Invariants###
### Models###
### Models###
StandardDSS6Computer, StabbingLineComputer, StabbingCircleComputer
StandardDSS6Computer, StabbingLineComputer, StabbingCircleComputer
### Notes###
### Notes###
@tparam T the type that should be a model of CBidirectionalSegmentComputer.
*/
template <typename T>
struct CBidirectionalSegmentComputer : CForwardSegmentComputer<T>
{
// ----------------------- Concept checks ------------------------------
public:
// Methods
BOOST_CONCEPT_USAGE( CBidirectionalSegmentComputer )
@tparam T the type that should be a model of CBidirectionalSegmentComputer.
*/
template <typename T>
struct CBidirectionalSegmentComputer : concepts::CForwardSegmentComputer<T>
{
concepts::ConceptUtils::sameType( myB, myX.isExtendableBack() );
concepts::ConceptUtils::sameType( myB, myX.extendBack() );
}
// ------------------------- Private Datas --------------------------------
private:
T myX; // only if T is default constructible.
bool myB;
// ----------------------- Concept checks ------------------------------
public:
// Methods
BOOST_CONCEPT_USAGE( CBidirectionalSegmentComputer )
{
concepts::ConceptUtils::sameType( myB, myX.isExtendableBack() );
concepts::ConceptUtils::sameType( myB, myX.extendBack() );
}
// ------------------------- Private Datas --------------------------------
private:
T myX; // only if T is default constructible.
bool myB;

// ------------------------- Internals ------------------------------------
private:
// ------------------------- Internals ------------------------------------
private:

}; // end of concept CBidirectionalSegmentComputer

}; // end of concept CBidirectionalSegmentComputer
} //namespace concepts
} // namespace DGtal

// //
Expand Down
79 changes: 40 additions & 39 deletions src/DGtal/geometry/curves/CDynamicBidirectionalSegmentComputer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,55 +49,56 @@

namespace DGtal
{
namespace concepts
{
/////////////////////////////////////////////////////////////////////////////
// class CDynamicBidirectionalSegmentComputer
/**
Description of \b concept '\b CDynamicBidirectionalSegmentComputer' <p>
@ingroup Concepts
@brief Aim: Defines the concept describing a dynamic and bidirectional
segment computer, ie. a model of concepts::CSegment that can extend and retract itself
in either direction.
/////////////////////////////////////////////////////////////////////////////
// class CDynamicBidirectionalSegmentComputer
/**
Description of \b concept '\b CDynamicBidirectionalSegmentComputer' <p>
@ingroup Concepts
@brief Aim: Defines the concept describing a dynamic and bidirectional
segment computer, ie. a model of CSegment that can extend and retract itself
in either direction.
### Refinement of CBidirectionalSegmentComputer and CDynamicSegmentComputer
### Refinement of concepts::CBidirectionalSegmentComputer and concepts::CDynamicSegmentComputer
### Valid expressions and semantics
### Valid expressions and semantics
| Name | Expression | Type requirements | Return type | Precondition | Semantics | Post condition | Complexity |
|---------------|------------|---------------------|-------------|------------------|-----------|----------------|------------|
| Backward retraction | x.retractFront() | |bool | | returns 'true' if --x.end() != x.begin() (and decrements the end iterator), 'false' otherwise | | |
| Name | Expression | Type requirements | Return type | Precondition | Semantics | Post condition | Complexity |
|---------------|------------|---------------------|-------------|------------------|-----------|----------------|------------|
| Backward retraction | x.retractFront() | |bool | | returns 'true' if --x.end() != x.begin() (and decrements the end iterator), 'false' otherwise | | |
### Models###
### Models###
ArithmeticalDSSComputer, OneBalancedWordComputer
ArithmeticalDSSComputer, OneBalancedWordComputer
### Notes###
### Notes###
@tparam T the type that should be a model of CDynamicBidirectionalSegmentComputer.
*/
template <typename T>
struct CDynamicBidirectionalSegmentComputer :
CBidirectionalSegmentComputer<T>,
CDynamicSegmentComputer<T>
{
// ----------------------- Concept checks ------------------------------
public:
// Methods
BOOST_CONCEPT_USAGE( CDynamicBidirectionalSegmentComputer )
@tparam T the type that should be a model of CDynamicBidirectionalSegmentComputer.
*/
template <typename T>
struct CDynamicBidirectionalSegmentComputer :
concepts::CBidirectionalSegmentComputer<T>,
concepts::CDynamicSegmentComputer<T>
{
concepts::ConceptUtils::sameType( myB, myX.retractFront() );
}
// ------------------------- Private Datas --------------------------------
private:
T myX; // only if T is default constructible.
bool myB;

// ------------------------- Internals ------------------------------------
private:
}; // end of concept CDynamicBidirectionalSegmentComputer

// ----------------------- Concept checks ------------------------------
public:
// Methods
BOOST_CONCEPT_USAGE( CDynamicBidirectionalSegmentComputer )
{
concepts::ConceptUtils::sameType( myB, myX.retractFront() );
}
// ------------------------- Private Datas --------------------------------
private:
T myX; // only if T is default constructible.
bool myB;

// ------------------------- Internals ------------------------------------
private:
}; // end of concept CDynamicBidirectionalSegmentComputer
}// namespace concepts
} // namespace DGtal

// //
Expand Down
7 changes: 4 additions & 3 deletions src/DGtal/geometry/curves/CDynamicSegmentComputer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@

namespace DGtal
{

namespace concepts
{
/////////////////////////////////////////////////////////////////////////////
// class CDynamicSegmentComputer
/**
Expand Down Expand Up @@ -84,7 +85,7 @@ Description of \b concept '\b CDynamicSegmentComputer' <p>
@tparam T the type that should be a model of CDynamicSegmentComputer.
*/
template <typename T>
struct CDynamicSegmentComputer : CForwardSegmentComputer<T>
struct CDynamicSegmentComputer : concepts::CForwardSegmentComputer<T>
{
// ----------------------- Concept checks ------------------------------
public:
Expand All @@ -102,7 +103,7 @@ Description of \b concept '\b CDynamicSegmentComputer' <p>
private:

}; // end of concept CDynamicSegmentComputer

}
} // namespace DGtal

// //
Expand Down
Loading

0 comments on commit fe9e169

Please sign in to comment.