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

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 @@ ...@@ -9,12 +9,14 @@
//========================================================================= //=========================================================================
#include <functional> #include <functional>
struct favorite_int { struct favorite_int
int operator() () { return 42; } {
int operator()() { return 42; }
}; };
struct conditional_int { struct conditional_int
int operator() (float x) { return 2 * static_cast<int>(x); } {
int operator()(float x) { return 2 * static_cast<int>(x); }
}; };
int main(int, char**) int main(int, char**)
...@@ -23,5 +25,5 @@ int main(int, char**) ...@@ -23,5 +25,5 @@ int main(int, char**)
f = favorite_int(); f = favorite_int();
std::function<int()> g; std::function<int()> g;
g = std::bind<float>(conditional_int(), 21.0); 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 @@ ...@@ -13,12 +13,14 @@
#include <boost/functional.hpp> #include <boost/functional.hpp>
#include <boost/mpl/placeholders.hpp> #include <boost/mpl/placeholders.hpp>
struct favorite_int { struct favorite_int
int operator() () { return 42; } {
int operator()() { return 42; }
}; };
struct conditional_int { struct conditional_int
int operator() (float x) { return 2 * static_cast<int>(x); } {
int operator()(float x) { return 2 * static_cast<int>(x); }
}; };
int main(int, char**) int main(int, char**)
...@@ -27,5 +29,5 @@ int main(int, char**) ...@@ -27,5 +29,5 @@ int main(int, char**)
f = favorite_int(); f = favorite_int();
boost::function<int()> g; boost::function<int()> g;
g = boost::bind<float>(conditional_int(), 21.0); 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 @@ ...@@ -9,12 +9,14 @@
//========================================================================= //=========================================================================
#include <tr1/functional> #include <tr1/functional>
struct favorite_int { struct favorite_int
int operator() () { return 42; } {
int operator()() { return 42; }
}; };
struct conditional_int { struct conditional_int
int operator() (float x) { return 2 * static_cast<int>(x); } {
int operator()(float x) { return 2 * static_cast<int>(x); }
}; };
int main(int, char**) int main(int, char**)
...@@ -23,5 +25,5 @@ int main(int, char**) ...@@ -23,5 +25,5 @@ int main(int, char**)
f = favorite_int(); f = favorite_int();
std::tr1::function<int()> g; std::tr1::function<int()> g;
g = std::tr1::bind<float>(conditional_int(), 21.0); 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 @@ ...@@ -19,9 +19,12 @@
class vtkUnstructuredGrid; class vtkUnstructuredGrid;
namespace smtk { namespace smtk
namespace bridge { {
namespace tutorial { namespace bridge
{
namespace tutorial
{
// ++ 2 ++ // ++ 2 ++
/// The types of entities in a VTK "model" /// The types of entities in a VTK "model"
...@@ -35,7 +38,8 @@ enum EntityType ...@@ -35,7 +38,8 @@ enum EntityType
}; };
/// A "handle" for a VTK entity (point, cell, property, etc.) /// A "handle" for a VTK entity (point, cell, property, etc.)
struct EntityHandle { struct EntityHandle
{
EntityType entityType; //!< Describes the type of VTK entity EntityType entityType; //!< Describes the type of VTK entity
int entityRelation; //!< A modifier for the entity type (to select an array or boundary) 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. vtkIdType entityId; //!< The offset in the array of entities describing this entity.
...@@ -61,41 +65,31 @@ public: ...@@ -61,41 +65,31 @@ public:
smtk::model::EntityRef toEntityRef(const EntityHandle& ent); smtk::model::EntityRef toEntityRef(const EntityHandle& ent);
// These methods may be provided as needed. // These methods may be provided as needed.
static int staticSetup( static int staticSetup(const std::string& optName, const smtk::model::StringList& optVal);
const std::string& optName, virtual int setup(const std::string& optName, const smtk::model::StringList& optVal);
const smtk::model::StringList& optVal);
virtual int setup(
const std::string& optName,
const smtk::model::StringList& optVal);
protected: protected:
Session(); Session();
// This is required of every session: // This is required of every session:
virtual SessionInfoBits transcribeInternal( virtual SessionInfoBits transcribeInternal(
const smtk::model::EntityRef& entity, const smtk::model::EntityRef& entity, SessionInfoBits requestedInfo);
SessionInfoBits requestedInfo);
vtkSmartPointer<vtkUnstructuredGrid> Model; vtkSmartPointer<vtkUnstructuredGrid> Model;
// ... }; // ... };
// -- 1 -- // -- 1 --
void addRelations( void addRelations(smtk::model::EntityRef& entityref, std::vector<EntityHandle>& rels,
smtk::model::EntityRef& entityref, SessionInfoBits requestedInfo, int depth);
std::vector<EntityHandle>& rels, bool addTessellation(const smtk::model::EntityRef&, const EntityHandle&);
SessionInfoBits requestedInfo,
int depth);
bool addTessellation(
const smtk::model::EntityRef&,
const EntityHandle&);
private: private:
Session(const Session&); // Not implemented. Session(const Session&); // Not implemented.
void operator = (const Session&); // Not implemented. void operator=(const Session&); // Not implemented.
}; };
} // namespace tutorial } // namespace tutorial
} // namespace bridge } // namespace bridge
} // namespace smtk } // namespace smtk
#endif // __smtk_ex_session_h #endif // __smtk_ex_session_h
...@@ -5,10 +5,7 @@ ...@@ -5,10 +5,7 @@
int main() int main()
{ {
std::cout std::cout << "Compiled with SMTK version " << smtk::common::Version::number() << "\n";
<< "Compiled with SMTK version "
<< smtk::common::Version::number()
<< "\n";
return 0; return 0;
} }
// -- 1 -- // -- 1 --
...@@ -31,7 +31,8 @@ using namespace smtk::common; ...@@ -31,7 +31,8 @@ using namespace smtk::common;
using namespace smtk::model; using namespace smtk::model;
using smtk::attribute::IntItem; using smtk::attribute::IntItem;
namespace ex { namespace ex
{
// ++ 2 ++ // ++ 2 ++
OperatorResult CounterOperator::operateInternal() OperatorResult CounterOperator::operateInternal()
...@@ -40,28 +41,22 @@ OperatorResult CounterOperator::operateInternal() ...@@ -40,28 +41,22 @@ OperatorResult CounterOperator::operateInternal()
OperatorSpecification params = this->specification(); OperatorSpecification params = this->specification();
// Get the input model to be processed: // Get the input model to be processed:
Model model = Model model = params->findModelEntity("model")->value();
params->findModelEntity("model")->value();
// Decide whether we should count cells or groups // Decide whether we should count cells or groups
// of the model: // of the model:
int countGroups = int countGroups = params->findInt("count groups")->value();
params->findInt("count groups")->value();
// Create the attribute holding the results of // Create the attribute holding the results of
// our operation using a convenience method // our operation using a convenience method
// provided by the Operator base class. // provided by the Operator base class.
// Our operation is simple; we always succeed. // Our operation is simple; we always succeed.
OperatorResult result = OperatorResult result = this->createResult(OPERATION_SUCCEEDED);
this->createResult(OPERATION_SUCCEEDED);
// Fetch the item to store our output: // Fetch the item to store our output:
smtk::attribute::IntItemPtr cellCount = smtk::attribute::IntItemPtr cellCount = result->findInt("count");
result->findInt("count");
cellCount->setValue(countGroups ? cellCount->setValue(countGroups ? model.groups().size() : model.cells().size());
model.groups().size() :
model.cells().size());
return result; return result;
} }
...@@ -89,22 +84,18 @@ void testOperator(Model model) ...@@ -89,22 +84,18 @@ void testOperator(Model model)
// Ask the session to create an operator: // Ask the session to create an operator:
ex::CounterOperator::Ptr op = ex::CounterOperator::Ptr op =
smtk::dynamic_pointer_cast<ex::CounterOperator>( smtk::dynamic_pointer_cast<ex::CounterOperator>(session->op("counter"));
session->op("counter"));
op->ensureSpecification(); op->ensureSpecification();
smtk::attribute::ModelEntityItemPtr input = smtk::attribute::ModelEntityItemPtr input = op->specification()->findModelEntity("model");
op->specification()->findModelEntity("model");
input->setValue(model); input->setValue(model);
test(!!op, "Could not create operator."); test(!!op, "Could not create operator.");
test( test(op->operate()->findInt("count")->value() == 1,
op->operate()->findInt("count")->value() == 1,
"Did not return the proper number of top-level cells."); "Did not return the proper number of top-level cells.");
op->specification()->findInt("count groups")->setValue(1); op->specification()->findInt("count groups")->setValue(1);
test( test(op->operate()->findInt("count")->value() == 0,
op->operate()->findInt("count")->value() == 0,
"Did not return the proper number of top-level group."); "Did not return the proper number of top-level group.");
} }
...@@ -121,12 +112,14 @@ int main() ...@@ -121,12 +112,14 @@ int main()
model.setSession(session); model.setSession(session);
model.addCell(tet); model.addCell(tet);
try { try
{
testOperator(model); testOperator(model);
}
} catch (const std::string& msg) { catch (const std::string& msg)
(void) msg; // Ignore the message; it's already been printed. {
(void)msg; // Ignore the message; it's already been printed.
std::cerr << "Exiting...\n"; std::cerr << "Exiting...\n";
status = -1; status = -1;
} }
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
#include <string> #include <string>
// ++ 1 ++ // ++ 1 ++
namespace ex { namespace ex
{
class CounterOperator : public smtk::model::Operator class CounterOperator : public smtk::model::Operator
{ {
...@@ -16,15 +17,14 @@ public: ...@@ -16,15 +17,14 @@ public:
smtkSharedFromThisMacro(Operator); smtkSharedFromThisMacro(Operator);
smtkDeclareModelOperator(); smtkDeclareModelOperator();
// ... // ...
// -- 1 -- // -- 1 --
// ++ 2 ++ // ++ 2 ++
virtual bool ableToOperate() virtual bool ableToOperate() { return this->ensureSpecification(); }
{ return this->ensureSpecification(); }
protected: protected:
virtual smtk::model::OperatorResult operateInternal(); virtual smtk::model::OperatorResult operateInternal();
// -- 2 -- // -- 2 --
}; };
} // namespace ex } // namespace ex
......
...@@ -21,10 +21,8 @@ ...@@ -21,10 +21,8 @@
#define smtkAutoInitComponentMacro(C) \ #define smtkAutoInitComponentMacro(C) \
void C##_AutoInit_Construct(); \ void C##_AutoInit_Construct(); \
void C##_AutoInit_Destruct(); void C##_AutoInit_Destruct();
#define smtkAutoInitConstructMacro(C) \ #define smtkAutoInitConstructMacro(C) C##_AutoInit_Construct();
C##_AutoInit_Construct(); #define smtkAutoInitDestructMacro(C) C##_AutoInit_Destruct();
#define smtkAutoInitDestructMacro(C) \
C##_AutoInit_Destruct();
/**\brief Register an SMTK component for use. /**\brief Register an SMTK component for use.
* *
...@@ -46,8 +44,8 @@ ...@@ -46,8 +44,8 @@
* smtk_cgm_session_AutoInit_Destruct is called during finalization. * smtk_cgm_session_AutoInit_Destruct is called during finalization.
*/ */
#define smtkComponentInitMacro(C) \ #define smtkComponentInitMacro(C) \
smtkAutoInitComponentMacro(C) \ smtkAutoInitComponentMacro(C) static struct C##_ComponentInit \
static struct C##_ComponentInit { \ { \
/* Call <mod>_AutoInit_Construct during initialization. */ \ /* Call <mod>_AutoInit_Construct during initialization. */ \
C##_ComponentInit() { smtkAutoInitConstructMacro(C) } \ C##_ComponentInit() { smtkAutoInitConstructMacro(C) } \
/* Call <mod>_AutoInit_Destruct during finalization. */ \ /* Call <mod>_AutoInit_Destruct during finalization. */ \
......
This diff is collapsed.
...@@ -41,21 +41,21 @@ ...@@ -41,21 +41,21 @@
* in a class hierarchy. * in a class hierarchy.
*/ */
#ifndef SHIBOKEN_SKIP #ifndef SHIBOKEN_SKIP
# define smtkTypeMacro(...) \ #define smtkTypeMacro(...) \
typedef __VA_ARGS__ SelfType; \ typedef __VA_ARGS__ SelfType; \
typedef smtk::shared_ptr< __VA_ARGS__ > Ptr; \ typedef smtk::shared_ptr<__VA_ARGS__> Ptr; \
typedef smtk::shared_ptr< const __VA_ARGS__ > ConstPtr; \ typedef smtk::shared_ptr<const __VA_ARGS__> ConstPtr; \
typedef smtk::weak_ptr< __VA_ARGS__ > WeakPtr; \ typedef smtk::weak_ptr<__VA_ARGS__> WeakPtr; \
typedef smtk::weak_ptr< const __VA_ARGS__ > WeakConstPtr; \ typedef smtk::weak_ptr<const __VA_ARGS__> WeakConstPtr; \
virtual std::string classname() const { return #__VA_ARGS__ ; } virtual std::string classname() const { return #__VA_ARGS__; }
#else #else
// This is required because shiboken cannot properly parse the #__VA_ARGS__ in classname() above: // This is required because shiboken cannot properly parse the #__VA_ARGS__ in classname() above:
# define smtkTypeMacro(...) \ #define smtkTypeMacro(...) \
typedef __VA_ARGS__ SelfType; \ typedef __VA_ARGS__ SelfType; \
typedef smtk::shared_ptr< __VA_ARGS__ > Ptr; \ typedef smtk::shared_ptr<__VA_ARGS__> Ptr; \
typedef smtk::shared_ptr< const __VA_ARGS__ > ConstPtr; \ typedef smtk::shared_ptr<const __VA_ARGS__> ConstPtr; \
typedef smtk::weak_ptr< __VA_ARGS__ > WeakPtr; \ typedef smtk::weak_ptr<__VA_ARGS__> WeakPtr; \
typedef smtk::weak_ptr< const __VA_ARGS__ > WeakConstPtr typedef smtk::weak_ptr<const __VA_ARGS__> WeakConstPtr
#endif #endif
/**\brief Add a typedef to the superclass of this class. /**\brief Add a typedef to the superclass of this class.
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
*/ */
#define smtkSuperclassMacro(...) \ #define smtkSuperclassMacro(...) \
typedef __VA_ARGS__ Superclass; \ 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. /**\brief Add static create() methods to a class.
* *
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
#define smtkCreateMacro(...) \ #define smtkCreateMacro(...) \
static smtk::shared_ptr<SelfType> create() \ 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); \ return smtk::static_pointer_cast<SelfType>(shared); \
} \ } \
/* variant for declarative programming: */ \ /* variant for declarative programming: */ \
...@@ -133,7 +133,8 @@ ...@@ -133,7 +133,8 @@
* call smtkCreateMacro() as a safe way to expose public construction. * call smtkCreateMacro() as a safe way to expose public construction.
*/ */
#define smtkEnableSharedPtr(...) \ #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(). /**\brief A macro to help with derived classes whose bases enable shared_from_this().
* *
...@@ -170,19 +171,17 @@ ...@@ -170,19 +171,17 @@
typedef __VA_ARGS__ SharedPtrBaseType; \ typedef __VA_ARGS__ SharedPtrBaseType; \
smtk::shared_ptr<SelfType> shared_from_this() \ smtk::shared_ptr<SelfType> shared_from_this() \
{ \ { \
return smtk::static_pointer_cast<SelfType>( \ return smtk::static_pointer_cast<SelfType>(SharedPtrBaseType::shared_from_this()); \
SharedPtrBaseType::shared_from_this()); \
} \ } \
smtk::shared_ptr<const SelfType> shared_from_this() const \ smtk::shared_ptr<const SelfType> shared_from_this() const \
{ \ { \
return smtk::static_pointer_cast<const SelfType>( \ return smtk::static_pointer_cast<const SelfType>(SharedPtrBaseType::shared_from_this()); \
SharedPtrBaseType::shared_from_this()); \
} }
/// A convenience macro for declaring shared_from_this and create methods. /// A convenience macro for declaring shared_from_this and create methods.
#define smtkSharedPtrCreateMacro(...) \ #define smtkSharedPtrCreateMacro(...) \
smtkSharedFromThisMacro( __VA_ARGS__ ); \ smtkSharedFromThisMacro(__VA_ARGS__); \
smtkCreateMacro( __VA_ARGS__ ) smtkCreateMacro(__VA_ARGS__)
/**\brief A convenience macro to use in the body of create methods that take arguments. /**\brief A convenience macro to use in the body of create methods that take arguments.
* *
...@@ -216,10 +215,6 @@ ...@@ -216,10 +215,6 @@
* to premature deletion or multiple-deletion. * to premature deletion or multiple-deletion.
*/ */
#define smtkSharedPtrHelper(...) \ #define smtkSharedPtrHelper(...) \
smtk::static_pointer_cast<SelfType>( \ smtk::static_pointer_cast<SelfType>(SharedPtrBaseType::Ptr(__VA_ARGS__))
SharedPtrBaseType::Ptr( \
__VA_ARGS__ \
) \
)
#endif // __smtk_SharedFromThis_h #endif // __smtk_SharedFromThis_h
...@@ -18,29 +18,29 @@ ...@@ -18,29 +18,29 @@
namespace smtk namespace smtk
{ {
//bring the correct shared_ptr implementation into our project namespace //bring the correct shared_ptr implementation into our project namespace
using std::shared_ptr; using std::shared_ptr;
//bring the correct make_shared implementation into our project namespace //bring the correct make_shared implementation into our project namespace
using std::make_shared; using std::make_shared;
//bring the correct weak_ptr implementation into our project namespace //bring the correct weak_ptr implementation into our project namespace
using std::weak_ptr; using std::weak_ptr;
//bring in the correct shared_ptr dynamic cast //bring in the correct shared_ptr dynamic cast
using std::dynamic_pointer_cast; using std::dynamic_pointer_cast;
//bring in the correct shared_ptr const_pointer_cast //bring in the correct shared_ptr const_pointer_cast
using std::const_pointer_cast; using std::const_pointer_cast;
//bring in the correct shared_ptr static_pointer_cast //bring in the correct shared_ptr static_pointer_cast
using std::static_pointer_cast; using std::static_pointer_cast;