Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

Commit 5630b522 authored by Kitware Robot's avatar Kitware Robot Committed by Ben Boeckel

clang-format: format the entire codebase

This allows the robot to enforce formatting and fix formatting issues
automatically.
parent 6a034a08
Pipeline #56466 passed with stage

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
......@@ -9,12 +9,14 @@
//=========================================================================
#include <functional>
struct favorite_int {
int operator() () { return 42; }
struct favorite_int
{
int operator()() { return 42; }
};
struct conditional_int {
int operator() (float x) { return 2 * static_cast<int>(x); }
struct conditional_int
{
int operator()(float x) { return 2 * static_cast<int>(x); }
};
int main(int, char**)
......@@ -23,5 +25,5 @@ int main(int, char**)
f = favorite_int();
std::function<int()> g;
g = std::bind<float>(conditional_int(), 21.0);
return (f() == 42 && g() == 42 ) ? 0 : 1;
return (f() == 42 && g() == 42) ? 0 : 1;
}
......@@ -13,12 +13,14 @@
#include <boost/functional.hpp>
#include <boost/mpl/placeholders.hpp>
struct favorite_int {
int operator() () { return 42; }
struct favorite_int
{
int operator()() { return 42; }
};
struct conditional_int {
int operator() (float x) { return 2 * static_cast<int>(x); }
struct conditional_int
{
int operator()(float x) { return 2 * static_cast<int>(x); }
};
int main(int, char**)
......@@ -27,5 +29,5 @@ int main(int, char**)
f = favorite_int();
boost::function<int()> g;
g = boost::bind<float>(conditional_int(), 21.0);
return (f() == 42 && g() == 42 ) ? 0 : 1;
return (f() == 42 && g() == 42) ? 0 : 1;
}
......@@ -9,12 +9,14 @@
//=========================================================================
#include <tr1/functional>
struct favorite_int {
int operator() () { return 42; }
struct favorite_int
{
int operator()() { return 42; }
};
struct conditional_int {
int operator() (float x) { return 2 * static_cast<int>(x); }
struct conditional_int
{
int operator()(float x) { return 2 * static_cast<int>(x); }
};
int main(int, char**)
......@@ -23,5 +25,5 @@ int main(int, char**)
f = favorite_int();
std::tr1::function<int()> g;
g = std::tr1::bind<float>(conditional_int(), 21.0);
return (f() == 42 && g() == 42 ) ? 0 : 1;
return (f() == 42 && g() == 42) ? 0 : 1;
}
......@@ -19,9 +19,12 @@
class vtkUnstructuredGrid;
namespace smtk {
namespace bridge {
namespace tutorial {
namespace smtk
{
namespace bridge
{
namespace tutorial
{
// ++ 2 ++
/// The types of entities in a VTK "model"
......@@ -35,7 +38,8 @@ enum EntityType
};
/// A "handle" for a VTK entity (point, cell, property, etc.)
struct EntityHandle {
struct EntityHandle
{
EntityType entityType; //!< Describes the type of VTK entity
int entityRelation; //!< A modifier for the entity type (to select an array or boundary)
vtkIdType entityId; //!< The offset in the array of entities describing this entity.
......@@ -61,41 +65,31 @@ public:
smtk::model::EntityRef toEntityRef(const EntityHandle& ent);
// These methods may be provided as needed.
static int staticSetup(
const std::string& optName,
const smtk::model::StringList& optVal);
virtual int setup(
const std::string& optName,
const smtk::model::StringList& optVal);
static int staticSetup(const std::string& optName, const smtk::model::StringList& optVal);
virtual int setup(const std::string& optName, const smtk::model::StringList& optVal);
protected:
Session();
// This is required of every session:
virtual SessionInfoBits transcribeInternal(
const smtk::model::EntityRef& entity,
SessionInfoBits requestedInfo);
const smtk::model::EntityRef& entity, SessionInfoBits requestedInfo);
vtkSmartPointer<vtkUnstructuredGrid> Model;
// ... };
// -- 1 --
void addRelations(
smtk::model::EntityRef& entityref,
std::vector<EntityHandle>& rels,
SessionInfoBits requestedInfo,
int depth);
bool addTessellation(
const smtk::model::EntityRef&,
const EntityHandle&);
void addRelations(smtk::model::EntityRef& entityref, std::vector<EntityHandle>& rels,
SessionInfoBits requestedInfo, int depth);
bool addTessellation(const smtk::model::EntityRef&, const EntityHandle&);
private:
Session(const Session&); // Not implemented.
void operator = (const Session&); // Not implemented.
void operator=(const Session&); // Not implemented.
};
} // namespace tutorial
} // namespace bridge
} // namespace tutorial
} // namespace bridge
} // namespace smtk
#endif // __smtk_ex_session_h
......@@ -5,10 +5,7 @@
int main()
{
std::cout
<< "Compiled with SMTK version "
<< smtk::common::Version::number()
<< "\n";
std::cout << "Compiled with SMTK version " << smtk::common::Version::number() << "\n";
return 0;
}
// -- 1 --
......@@ -31,7 +31,8 @@ using namespace smtk::common;
using namespace smtk::model;
using smtk::attribute::IntItem;
namespace ex {
namespace ex
{
// ++ 2 ++
OperatorResult CounterOperator::operateInternal()
......@@ -40,28 +41,22 @@ OperatorResult CounterOperator::operateInternal()
OperatorSpecification params = this->specification();
// Get the input model to be processed:
Model model =
params->findModelEntity("model")->value();
Model model = params->findModelEntity("model")->value();
// Decide whether we should count cells or groups
// of the model:
int countGroups =
params->findInt("count groups")->value();
int countGroups = params->findInt("count groups")->value();
// Create the attribute holding the results of
// our operation using a convenience method
// provided by the Operator base class.
// Our operation is simple; we always succeed.
OperatorResult result =
this->createResult(OPERATION_SUCCEEDED);
OperatorResult result = this->createResult(OPERATION_SUCCEEDED);
// Fetch the item to store our output:
smtk::attribute::IntItemPtr cellCount =
result->findInt("count");
smtk::attribute::IntItemPtr cellCount = result->findInt("count");
cellCount->setValue(countGroups ?
model.groups().size() :
model.cells().size());
cellCount->setValue(countGroups ? model.groups().size() : model.cells().size());
return result;
}
......@@ -89,22 +84,18 @@ void testOperator(Model model)
// Ask the session to create an operator:
ex::CounterOperator::Ptr op =
smtk::dynamic_pointer_cast<ex::CounterOperator>(
session->op("counter"));
smtk::dynamic_pointer_cast<ex::CounterOperator>(session->op("counter"));
op->ensureSpecification();
smtk::attribute::ModelEntityItemPtr input =
op->specification()->findModelEntity("model");
smtk::attribute::ModelEntityItemPtr input = op->specification()->findModelEntity("model");
input->setValue(model);
test(!!op, "Could not create operator.");
test(
op->operate()->findInt("count")->value() == 1,
test(op->operate()->findInt("count")->value() == 1,
"Did not return the proper number of top-level cells.");
op->specification()->findInt("count groups")->setValue(1);
test(
op->operate()->findInt("count")->value() == 0,
test(op->operate()->findInt("count")->value() == 0,
"Did not return the proper number of top-level group.");
}
......@@ -121,12 +112,14 @@ int main()
model.setSession(session);
model.addCell(tet);
try {
try
{
testOperator(model);
} catch (const std::string& msg) {
(void) msg; // Ignore the message; it's already been printed.
}
catch (const std::string& msg)
{
(void)msg; // Ignore the message; it's already been printed.
std::cerr << "Exiting...\n";
status = -1;
}
......
......@@ -6,7 +6,8 @@
#include <string>
// ++ 1 ++
namespace ex {
namespace ex
{
class CounterOperator : public smtk::model::Operator
{
......@@ -16,15 +17,14 @@ public:
smtkSharedFromThisMacro(Operator);
smtkDeclareModelOperator();
// ...
// -- 1 --
// -- 1 --
// ++ 2 ++
virtual bool ableToOperate()
{ return this->ensureSpecification(); }
// ++ 2 ++
virtual bool ableToOperate() { return this->ensureSpecification(); }
protected:
virtual smtk::model::OperatorResult operateInternal();
// -- 2 --
// -- 2 --
};
} // namespace ex
......
......@@ -21,10 +21,8 @@
#define smtkAutoInitComponentMacro(C) \
void C##_AutoInit_Construct(); \
void C##_AutoInit_Destruct();
#define smtkAutoInitConstructMacro(C) \
C##_AutoInit_Construct();
#define smtkAutoInitDestructMacro(C) \
C##_AutoInit_Destruct();
#define smtkAutoInitConstructMacro(C) C##_AutoInit_Construct();
#define smtkAutoInitDestructMacro(C) C##_AutoInit_Destruct();
/**\brief Register an SMTK component for use.
*
......@@ -46,8 +44,8 @@
* smtk_cgm_session_AutoInit_Destruct is called during finalization.
*/
#define smtkComponentInitMacro(C) \
smtkAutoInitComponentMacro(C) \
static struct C##_ComponentInit { \
smtkAutoInitComponentMacro(C) static struct C##_ComponentInit \
{ \
/* Call <mod>_AutoInit_Construct during initialization. */ \
C##_ComponentInit() { smtkAutoInitConstructMacro(C) } \
/* Call <mod>_AutoInit_Destruct during finalization. */ \
......
This diff is collapsed.
......@@ -41,21 +41,21 @@
* in a class hierarchy.
*/
#ifndef SHIBOKEN_SKIP
# define smtkTypeMacro(...) \
#define smtkTypeMacro(...) \
typedef __VA_ARGS__ SelfType; \
typedef smtk::shared_ptr< __VA_ARGS__ > Ptr; \
typedef smtk::shared_ptr< const __VA_ARGS__ > ConstPtr; \
typedef smtk::weak_ptr< __VA_ARGS__ > WeakPtr; \
typedef smtk::weak_ptr< const __VA_ARGS__ > WeakConstPtr; \
virtual std::string classname() const { return #__VA_ARGS__ ; }
typedef smtk::shared_ptr<__VA_ARGS__> Ptr; \
typedef smtk::shared_ptr<const __VA_ARGS__> ConstPtr; \
typedef smtk::weak_ptr<__VA_ARGS__> WeakPtr; \
typedef smtk::weak_ptr<const __VA_ARGS__> WeakConstPtr; \
virtual std::string classname() const { return #__VA_ARGS__; }
#else
// This is required because shiboken cannot properly parse the #__VA_ARGS__ in classname() above:
# define smtkTypeMacro(...) \
#define smtkTypeMacro(...) \
typedef __VA_ARGS__ SelfType; \
typedef smtk::shared_ptr< __VA_ARGS__ > Ptr; \
typedef smtk::shared_ptr< const __VA_ARGS__ > ConstPtr; \
typedef smtk::weak_ptr< __VA_ARGS__ > WeakPtr; \
typedef smtk::weak_ptr< const __VA_ARGS__ > WeakConstPtr
typedef smtk::shared_ptr<__VA_ARGS__> Ptr; \
typedef smtk::shared_ptr<const __VA_ARGS__> ConstPtr; \
typedef smtk::weak_ptr<__VA_ARGS__> WeakPtr; \
typedef smtk::weak_ptr<const __VA_ARGS__> WeakConstPtr
#endif
/**\brief Add a typedef to the superclass of this class.
......@@ -71,7 +71,7 @@
*/
#define smtkSuperclassMacro(...) \
typedef __VA_ARGS__ Superclass; \
typedef smtk::shared_ptr< __VA_ARGS__ > SuperclassPtr
typedef smtk::shared_ptr<__VA_ARGS__> SuperclassPtr
/**\brief Add static create() methods to a class.
*
......@@ -97,7 +97,7 @@
#define smtkCreateMacro(...) \
static smtk::shared_ptr<SelfType> create() \
{ \
smtk::shared_ptr< __VA_ARGS__ > shared(new SelfType); \
smtk::shared_ptr<__VA_ARGS__> shared(new SelfType); \
return smtk::static_pointer_cast<SelfType>(shared); \
} \
/* variant for declarative programming: */ \
......@@ -133,7 +133,8 @@
* call smtkCreateMacro() as a safe way to expose public construction.
*/
#define smtkEnableSharedPtr(...) \
public smtk::enable_shared_from_this< __VA_ARGS__ >
public \
smtk::enable_shared_from_this<__VA_ARGS__>
/**\brief A macro to help with derived classes whose bases enable shared_from_this().
*
......@@ -170,19 +171,17 @@
typedef __VA_ARGS__ SharedPtrBaseType; \
smtk::shared_ptr<SelfType> shared_from_this() \
{ \
return smtk::static_pointer_cast<SelfType>( \
SharedPtrBaseType::shared_from_this()); \
return smtk::static_pointer_cast<SelfType>(SharedPtrBaseType::shared_from_this()); \
} \
smtk::shared_ptr<const SelfType> shared_from_this() const \
{ \
return smtk::static_pointer_cast<const SelfType>( \
SharedPtrBaseType::shared_from_this()); \
return smtk::static_pointer_cast<const SelfType>(SharedPtrBaseType::shared_from_this()); \
}
/// A convenience macro for declaring shared_from_this and create methods.
#define smtkSharedPtrCreateMacro(...) \
smtkSharedFromThisMacro( __VA_ARGS__ ); \
smtkCreateMacro( __VA_ARGS__ )
smtkSharedFromThisMacro(__VA_ARGS__); \
smtkCreateMacro(__VA_ARGS__)
/**\brief A convenience macro to use in the body of create methods that take arguments.
*
......@@ -216,10 +215,6 @@
* to premature deletion or multiple-deletion.
*/
#define smtkSharedPtrHelper(...) \
smtk::static_pointer_cast<SelfType>( \
SharedPtrBaseType::Ptr( \
__VA_ARGS__ \
) \
)
smtk::static_pointer_cast<SelfType>(SharedPtrBaseType::Ptr(__VA_ARGS__))
#endif // __smtk_SharedFromThis_h
......@@ -18,29 +18,29 @@
namespace smtk
{
//bring the correct shared_ptr implementation into our project namespace
using std::shared_ptr;
//bring the correct shared_ptr implementation into our project namespace
using std::shared_ptr;
//bring the correct make_shared implementation into our project namespace
using std::make_shared;
//bring the correct make_shared implementation into our project namespace
using std::make_shared;
//bring the correct weak_ptr implementation into our project namespace
using std::weak_ptr;
//bring the correct weak_ptr implementation into our project namespace
using std::weak_ptr;
//bring in the correct shared_ptr dynamic cast
using std::dynamic_pointer_cast;
//bring in the correct shared_ptr dynamic cast
using std::dynamic_pointer_cast;
//bring in the correct shared_ptr const_pointer_cast
using std::const_pointer_cast;
//bring in the correct shared_ptr const_pointer_cast
using std::const_pointer_cast;
//bring in the correct shared_ptr static_pointer_cast
using std::static_pointer_cast;
//bring in the correct shared_ptr static_pointer_cast
using std::static_pointer_cast;
//bring in the correct enable_shared_from_this
using std::enable_shared_from_this;
//bring in the correct enable_shared_from_this
using std::enable_shared_from_this;
//bring in the correct owner_less so that
//we store weak ptr in sets/maps even more safely
using std::owner_less;
//bring in the correct owner_less so that
//we store weak ptr in sets/maps even more safely
using std::owner_less;
}
#endif /* __smtk_SharedPtr_h */
......@@ -17,16 +17,16 @@
//Windows specific stuff
#if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__)
# if !defined(SMTK_DISPLAY_INGORED_WIN_WARNINGS)
# pragma warning ( disable : 4251 ) /* missing DLL-interface */
# endif //!defined(SMTK_DISPLAY_INGORED_WIN_WARNINGS)
#if !defined(SMTK_DISPLAY_INGORED_WIN_WARNINGS)
#pragma warning(disable : 4251) /* missing DLL-interface */
#endif //!defined(SMTK_DISPLAY_INGORED_WIN_WARNINGS)
#endif //Windows specific stuff
#define SMTK_BASE_TYPE(thisclass) \
virtual const char* classname() const { return #thisclass; }
#define SMTK_DERIVED_TYPE(thisclass,superclass) \
typedef superclass Superclass;\
#define SMTK_DERIVED_TYPE(thisclass, superclass) \
typedef superclass Superclass; \
SMTK_BASE_TYPE(thisclass)
#endif //__smtk_SystemConfig_h
......@@ -8,7 +8,6 @@
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/attribute/Attribute.h"
#include "smtk/attribute/DateTimeItem.h"
#include "smtk/attribute/Definition.h"
......@@ -44,21 +43,26 @@ SMTK_THIRDPARTY_POST_INCLUDE
using namespace smtk::attribute;
using namespace smtk::common;
Attribute::Attribute(const std::string &myName,
smtk::attribute::DefinitionPtr myDefinition,
const smtk::common::UUID &myId):
m_name(myName), m_id(myId), m_definition(myDefinition),
m_appliesToBoundaryNodes(false), m_appliesToInteriorNodes(false),
m_isColorSet(false), m_aboutToBeDeleted(false)
Attribute::Attribute(const std::string& myName, smtk::attribute::DefinitionPtr myDefinition,
const smtk::common::UUID& myId)
: m_name(myName)
, m_id(myId)
, m_definition(myDefinition)
, m_appliesToBoundaryNodes(false)
, m_appliesToInteriorNodes(false)
, m_isColorSet(false)
, m_aboutToBeDeleted(false)
{
this->m_definition->buildAttribute(this);
}
Attribute::Attribute(const std::string &myName,
smtk::attribute::DefinitionPtr myDefinition):
m_name(myName), m_definition(myDefinition),
m_appliesToBoundaryNodes(false), m_appliesToInteriorNodes(false),
m_isColorSet(false), m_aboutToBeDeleted(false)
Attribute::Attribute(const std::string& myName, smtk::attribute::DefinitionPtr myDefinition)
: m_name(myName)
, m_definition(myDefinition)
, m_appliesToBoundaryNodes(false)
, m_appliesToInteriorNodes(false)
, m_isColorSet(false)
, m_aboutToBeDeleted(false)
{
smtk::common::UUIDGenerator gen;
this->m_id = gen.random();
......@@ -69,7 +73,7 @@ Attribute::~Attribute()
{
this->m_aboutToBeDeleted = true;
// Clear all references to the attribute
std::map<smtk::attribute::RefItem *, std::set<std::size_t> >::iterator it;
std::map<smtk::attribute::RefItem*, std::set<std::size_t> >::iterator it;
for (it = this->m_references.begin(); it != this->m_references.end(); it++)
{
std::set<std::size_t>::iterator sit;
......@@ -79,7 +83,7 @@ Attribute::~Attribute()
}
}
this->removeAllItems();
}
}
void Attribute::removeAllItems()
{
......@@ -92,10 +96,10 @@ void Attribute::removeAllItems()
this->m_items.clear();
}
void Attribute::references(std::vector<smtk::attribute::ItemPtr> &list) const
void Attribute::references(std::vector<smtk::attribute::ItemPtr>& list) const
{
list.clear();
std::map<smtk::attribute::RefItem *, std::set<std::size_t> >::const_iterator it;
std::map<smtk::attribute::RefItem*, std::set<std::size_t> >::const_iterator it;
for (it = this->m_references.begin(); it != this->m_references.end(); it++)
{
if (it->second.size())
......@@ -105,7 +109,7 @@ void Attribute::references(std::vector<smtk::attribute::ItemPtr> &list) const
}
}
const double *Attribute::color() const
const double* Attribute::color() const
{
if (this->m_isColorSet)
{
......@@ -114,7 +118,7 @@ const double *Attribute::color() const
return this->m_definition->defaultColor();
}
const std::string &Attribute::type() const
const std::string& Attribute::type() const
{
return this->m_definition->type();
}
......@@ -136,12 +140,12 @@ bool Attribute::isA(smtk::attribute::DefinitionPtr def) const
return this->m_definition->isA(def);
}
bool Attribute::isMemberOf(const std::string &category) const
bool Attribute::isMemberOf(const std::string& category) const
{
return this->m_definition->isMemberOf(category);
}
bool Attribute::isMemberOf(const std::vector<std::string> &categories) const
bool Attribute::isMemberOf(const std::vector<std::string>& categories) const
{
return this->m_definition->isMemberOf(categories);
}
......@@ -188,8 +192,7 @@ smtk::attribute::ConstItemPtr Attribute::itemAtPath(
return result;
}
smtk::attribute::ItemPtr Attribute::itemAtPath(
const std::string& path, const std::string& seps)
smtk::attribute::ItemPtr Attribute::itemAtPath(const std::string& path, const std::string& seps)