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 @@ ...@@ -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,26 +19,30 @@ ...@@ -19,26 +19,30 @@
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"
enum EntityType enum EntityType
{ {
VTK_POINT, // The entity is a point VTK_POINT, // The entity is a point
VTK_CELL, // The entity is a vertex, edge, face, or volume VTK_CELL, // The entity is a vertex, edge, face, or volume
VTK_GROUP, // The entity is a group (of points and/or cells) VTK_GROUP, // The entity is a group (of points and/or cells)
VTK_POINT_DATUM, // The entity is a property associated with a point VTK_POINT_DATUM, // The entity is a property associated with a point
VTK_CELL_DATUM // The entity is a property associated with a cell VTK_CELL_DATUM // The entity is a property associated with a cell
}; };
/// 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 {
int entityRelation; //!< A modifier for the entity type (to select an array or boundary) EntityType entityType; //!< Describes the type of VTK entity
vtkIdType entityId; //!< The offset in the array of entities describing this 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.
}; };
// -- 2 -- // -- 2 --
...@@ -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;
} }
...@@ -74,11 +69,11 @@ OperatorResult CounterOperator::operateInternal() ...@@ -74,11 +69,11 @@ OperatorResult CounterOperator::operateInternal()
// and provide an auto-init object for registering the // and provide an auto-init object for registering the
// operator with the session. // operator with the session.
smtkImplementsModelOperator( smtkImplementsModelOperator(
/* no export symbol */, // Export symbol (none here) /* no export symbol */, // Export symbol (none here)
ex::CounterOperator, // The class name (include all namespaces) ex::CounterOperator, // The class name (include all namespaces)
ex_counter, // The "component" name (for auto-init) ex_counter, // The "component" name (for auto-init)
"counter", // The user-printable operator name. "counter", // The user-printable operator name.
implement_an_operator_xml, // An XML description (or NULL). implement_an_operator_xml, // An XML description (or NULL).
smtk::model::DefaultSession); // The modeling kernel this operator uses. smtk::model::DefaultSession); // The modeling kernel this operator uses.
// -- 3 -- // -- 3 --
...@@ -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
......
...@@ -18,13 +18,11 @@ ...@@ -18,13 +18,11 @@
// See smtk/model/Session.h and its subclasses for an example of how // See smtk/model/Session.h and its subclasses for an example of how
// these macros are used to register components with the model Manager. // these macros are used to register components with the model Manager.
#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.
* *
...@@ -45,13 +43,13 @@ ...@@ -45,13 +43,13 @@
* dynamic C++ initialization and and the global function * dynamic C++ initialization and and the global function
* 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. */ \
~C##_ComponentInit() { smtkAutoInitDestructMacro(C) } \ ~C##_ComponentInit() { smtkAutoInitDestructMacro(C) } \
} C##_ComponentInit_Instance; } C##_ComponentInit_Instance;
#endif // __smtk_AutoInit_h #endif // __smtk_AutoInit_h
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.
...@@ -69,9 +69,9 @@ ...@@ -69,9 +69,9 @@
* parameters, since preprocessor macros do not properly * parameters, since preprocessor macros do not properly
* handle commas inside template parameter lists. * handle commas inside template parameter lists.
*/ */
#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.
* *
...@@ -94,18 +94,18 @@ ...@@ -94,18 +94,18 @@
* whose value is transformed before the returned value * whose value is transformed before the returned value
* can be assigned to a variable. * can be assigned to a variable.
*/ */
#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: */ \
static smtk::shared_ptr<SelfType> create(smtk::shared_ptr<SelfType>& ref) \ static smtk::shared_ptr<SelfType> create(smtk::shared_ptr<SelfType>& ref) \
{ \ { \
ref = SelfType::create(); \ ref = SelfType::create(); \
return ref; \ return ref; \
} }
/**\brief An abbreviation for enabling shared pointers. /**\brief An abbreviation for enabling shared pointers.
* *
...@@ -132,8 +132,9 @@ ...@@ -132,8 +132,9 @@
* For non-abstract classes, it is recommended that you * For non-abstract classes, it is recommended that you
* 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().
* *
...@@ -166,23 +167,21 @@ ...@@ -166,23 +167,21 @@
* in the derived class that returns a shared pointer * in the derived class that returns a shared pointer
* of the proper type. * of the proper type.
*/ */
#define smtkSharedFromThisMacro(...) \ #define smtkSharedFromThisMacro(...) \
typedef __VA_ARGS__ SharedPtrBaseType; \