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
......@@ -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,26 +19,30 @@
class vtkUnstructuredGrid;
namespace smtk {
namespace bridge {
namespace tutorial {
namespace smtk
{
namespace bridge
{
namespace tutorial
{
// ++ 2 ++
/// The types of entities in a VTK "model"
enum EntityType
{
VTK_POINT, // The entity is a point
VTK_CELL, // The entity is a vertex, edge, face, or volume
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_CELL_DATUM // The entity is a property associated with a cell
VTK_POINT, // The entity is a point
VTK_CELL, // The entity is a vertex, edge, face, or volume
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_CELL_DATUM // The entity is a property associated with a cell
};
/// A "handle" for a VTK entity (point, cell, property, etc.)
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.
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.
};
// -- 2 --
......@@ -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.
Session(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;
}
......@@ -74,11 +69,11 @@ OperatorResult CounterOperator::operateInternal()
// and provide an auto-init object for registering the
// operator with the session.
smtkImplementsModelOperator(
/* no export symbol */, // Export symbol (none here)
ex::CounterOperator, // The class name (include all namespaces)
ex_counter, // The "component" name (for auto-init)
"counter", // The user-printable operator name.
implement_an_operator_xml, // An XML description (or NULL).
/* no export symbol */, // Export symbol (none here)
ex::CounterOperator, // The class name (include all namespaces)
ex_counter, // The "component" name (for auto-init)
"counter", // The user-printable operator name.
implement_an_operator_xml, // An XML description (or NULL).
smtk::model::DefaultSession); // The modeling kernel this operator uses.
// -- 3 --
......@@ -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
......
......@@ -18,13 +18,11 @@
// See smtk/model/Session.h and its subclasses for an example of how
// these macros are used to register components with the model Manager.
#define smtkAutoInitComponentMacro(C) \
void C##_AutoInit_Construct(); \
#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.
*
......@@ -45,13 +43,13 @@
* dynamic C++ initialization and and the global function
* smtk_cgm_session_AutoInit_Destruct is called during finalization.
*/
#define smtkComponentInitMacro(C) \
smtkAutoInitComponentMacro(C) \
static struct C##_ComponentInit { \
/* Call <mod>_AutoInit_Construct during initialization. */ \
C##_ComponentInit() { smtkAutoInitConstructMacro(C) } \
/* Call <mod>_AutoInit_Destruct during finalization. */ \
~C##_ComponentInit() { smtkAutoInitDestructMacro(C) } \
#define smtkComponentInitMacro(C) \
smtkAutoInitComponentMacro(C) static struct C##_ComponentInit \
{ \
/* Call <mod>_AutoInit_Construct during initialization. */ \
C##_ComponentInit() { smtkAutoInitConstructMacro(C) } \
/* Call <mod>_AutoInit_Destruct during finalization. */ \
~C##_ComponentInit() { smtkAutoInitDestructMacro(C) } \
} C##_ComponentInit_Instance;
#endif // __smtk_AutoInit_h
This diff is collapsed.
......@@ -41,21 +41,21 @@
* in a class hierarchy.
*/
#ifndef SHIBOKEN_SKIP
# 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__ ; }
#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__; }
#else
// This is required because shiboken cannot properly parse the #__VA_ARGS__ in classname() above:
# 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
#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
#endif
/**\brief Add a typedef to the superclass of this class.
......@@ -69,9 +69,9 @@
* parameters, since preprocessor macros do not properly
* handle commas inside template parameter lists.
*/
#define smtkSuperclassMacro(...) \
typedef __VA_ARGS__ Superclass; \
typedef smtk::shared_ptr< __VA_ARGS__ > SuperclassPtr
#define smtkSuperclassMacro(...) \
typedef __VA_ARGS__ Superclass; \
typedef smtk::shared_ptr<__VA_ARGS__> SuperclassPtr
/**\brief Add static create() methods to a class.
*
......@@ -94,18 +94,18 @@
* whose value is transformed before the returned value
* can be assigned to a variable.
*/
#define smtkCreateMacro(...) \
static smtk::shared_ptr<SelfType> create() \
{ \
smtk::shared_ptr< __VA_ARGS__ > shared(new SelfType); \
return smtk::static_pointer_cast<SelfType>(shared); \
} \
/* variant for declarative programming: */ \
static smtk::shared_ptr<SelfType> create(smtk::shared_ptr<SelfType>& ref) \
{ \
ref = SelfType::create(); \
return ref; \
}
#define smtkCreateMacro(...) \
static smtk::shared_ptr<SelfType> create() \
{ \
smtk::shared_ptr<__VA_ARGS__> shared(new SelfType); \
return smtk::static_pointer_cast<SelfType>(shared); \
} \
/* variant for declarative programming: */ \
static smtk::shared_ptr<SelfType> create(smtk::shared_ptr<SelfType>& ref) \
{ \
ref = SelfType::create(); \
return ref; \
}
/**\brief An abbreviation for enabling shared pointers.
*
......@@ -132,8 +132,9 @@
* For non-abstract classes, it is recommended that you
* call smtkCreateMacro() as a safe way to expose public construction.
*/
#define smtkEnableSharedPtr(...) \
public smtk::enable_shared_from_this< __VA_ARGS__ >
#define smtkEnableSharedPtr(...) \
public \
smtk::enable_shared_from_this<__VA_ARGS__>
/**\brief A macro to help with derived classes whose bases enable shared_from_this().
*
......@@ -166,23 +167,21 @@
* in the derived class that returns a shared pointer
* of the proper type.
*/
#define smtkSharedFromThisMacro(...) \
typedef __VA_ARGS__ SharedPtrBaseType; \
smtk::shared_ptr<SelfType> 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()); \
}
#define smtkSharedFromThisMacro(...) \
typedef __VA_ARGS__ SharedPtrBaseType; \
smtk::shared_ptr<SelfType> 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()); \
}
/// A convenience macro for declaring shared_from_this and create methods.
#define smtkSharedPtrCreateMacro(...) \
smtkSharedFromThisMacro( __VA_ARGS__ ); \
smtkCreateMacro( __VA_ARGS__ )
#define smtkSharedPtrCreateMacro(...) \
smtkSharedFromThisMacro(__VA_ARGS__); \
smtkCreateMacro(__VA_ARGS__)
/**\brief A convenience macro to use in the body of create methods that take arguments.
*
......@@ -215,11 +214,7 @@
* be inserted into the wrong pool of shared pointers leading
* to premature deletion or multiple-deletion.
*/
#define smtkSharedPtrHelper(...) \
smtk::static_pointer_cast<SelfType>( \
SharedPtrBaseType::Ptr( \
__VA_ARGS__ \
) \
)
#define smtkSharedPtrHelper(...) \
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)
#endif //Windows specific stuff
#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) \
#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
This diff is collapsed.
This diff is collapsed.
......@@ -8,23 +8,22 @@
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/attribute/DateTimeItem.h"
#include "smtk/attribute/DateTimeItemDefinition.h"
namespace sc = smtk::common;
namespace smtk {
namespace attribute {
namespace smtk
{
namespace attribute
{
DateTimeItem::DateTimeItem(Attribute *owningAttribute, int itemPosition):
Item(owningAttribute, itemPosition)
DateTimeItem::DateTimeItem(Attribute* owningAttribute, int itemPosition)
: Item(owningAttribute, itemPosition)
{
}
DateTimeItem::DateTimeItem(
Item *inOwningAttribute, int itemPosition, int mySubGroupPosition):
Item(inOwningAttribute, itemPosition, mySubGroupPosition)
DateTimeItem::DateTimeItem(Item* inOwningAttribute, int itemPosition, int mySubGroupPosition)
: Item(inOwningAttribute, itemPosition, mySubGroupPosition)
{
}
......@@ -42,37 +41,37 @@ bool DateTimeItem::isValid() const
// If the item is not enabled or if all of its values are set then it is valid
// else it is enabled and contains unset values making it invalid
if (!this->isEnabled())