[Orxonox-commit 613] r3145 - in branches/pch/src: core orxonox/tools util
rgrieder at orxonox.net
rgrieder at orxonox.net
Thu Jun 11 18:22:16 CEST 2009
Author: rgrieder
Date: 2009-06-11 18:22:15 +0200 (Thu, 11 Jun 2009)
New Revision: 3145
Modified:
branches/pch/src/core/ClassFactory.h
branches/pch/src/core/Identifier.h
branches/pch/src/orxonox/tools/BulletConversions.h
branches/pch/src/orxonox/tools/TextureGenerator.cc
branches/pch/src/util/Convert.h
branches/pch/src/util/MathConvert.h
Log:
Added a few inline keywords to template functions (Visual Studio does not seem to inline the small ones if defined outside of the class)
Added FORCEINLINE (which expands to __forceinline for msvc) to all conversion functions (except the larger ones of course).
Modified: branches/pch/src/core/ClassFactory.h
===================================================================
--- branches/pch/src/core/ClassFactory.h 2009-06-10 20:58:53 UTC (rev 3144)
+++ branches/pch/src/core/ClassFactory.h 2009-06-11 16:22:15 UTC (rev 3145)
@@ -87,7 +87,7 @@
@return The new object
*/
template <class T>
- BaseObject* ClassFactory<T>::fabricate(BaseObject* creator)
+ inline BaseObject* ClassFactory<T>::fabricate(BaseObject* creator)
{
return ClassFactory<T>::createNewObject(creator);
}
@@ -97,7 +97,7 @@
@return The new object
*/
template <class T>
- T* ClassFactory<T>::createNewObject(BaseObject* creator)
+ inline T* ClassFactory<T>::createNewObject(BaseObject* creator)
{
return new T(creator);
}
Modified: branches/pch/src/core/Identifier.h
===================================================================
--- branches/pch/src/core/Identifier.h 2009-06-10 20:58:53 UTC (rev 3144)
+++ branches/pch/src/core/Identifier.h 2009-06-11 16:22:15 UTC (rev 3145)
@@ -382,7 +382,7 @@
@return The unique Identifier
*/
template <class T>
- ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
+ inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
{
// check if the static field has already been filled
if (ClassIdentifier<T>::classIdentifier_s == 0)
@@ -397,7 +397,7 @@
@return The Identifier
*/
template <class T>
- ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier(const std::string& name)
+ inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier(const std::string& name)
{
ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier();
identifier->setName(name);
@@ -434,7 +434,7 @@
@param object The object to add
*/
template <class T>
- void ClassIdentifier<T>::addObject(T* object)
+ inline void ClassIdentifier<T>::addObject(T* object)
{
COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
Modified: branches/pch/src/orxonox/tools/BulletConversions.h
===================================================================
--- branches/pch/src/orxonox/tools/BulletConversions.h 2009-06-10 20:58:53 UTC (rev 3144)
+++ branches/pch/src/orxonox/tools/BulletConversions.h 2009-06-11 16:22:15 UTC (rev 3145)
@@ -42,7 +42,7 @@
template <>
struct ConverterExplicit<orxonox::Vector3, btVector3>
{
- static bool convert(btVector3* output, const orxonox::Vector3& input)
+ FORCEINLINE static bool convert(btVector3* output, const orxonox::Vector3& input)
{
output->setX(input.x);
output->setY(input.y);
@@ -55,7 +55,7 @@
template <>
struct ConverterExplicit<btVector3, orxonox::Vector3>
{
- static bool convert(orxonox::Vector3* output, const btVector3& input)
+ FORCEINLINE static bool convert(orxonox::Vector3* output, const btVector3& input)
{
output->x = input.x();
output->y = input.y();
@@ -68,7 +68,7 @@
template <>
struct ConverterExplicit<orxonox::Quaternion, btQuaternion>
{
- static bool convert(btQuaternion* output, const orxonox::Quaternion& input)
+ FORCEINLINE static bool convert(btQuaternion* output, const orxonox::Quaternion& input)
{
output->setW(input.w);
output->setX(input.x);
@@ -82,7 +82,7 @@
template <>
struct ConverterExplicit<btQuaternion, orxonox::Quaternion>
{
- static bool convert(orxonox::Quaternion* output, const btQuaternion& input)
+ FORCEINLINE static bool convert(orxonox::Quaternion* output, const btQuaternion& input)
{
output->w = input.w();
output->x = input.x();
Modified: branches/pch/src/orxonox/tools/TextureGenerator.cc
===================================================================
--- branches/pch/src/orxonox/tools/TextureGenerator.cc 2009-06-10 20:58:53 UTC (rev 3144)
+++ branches/pch/src/orxonox/tools/TextureGenerator.cc 2009-06-11 16:22:15 UTC (rev 3145)
@@ -41,7 +41,7 @@
namespace std
{
template <>
- bool less<orxonox::ColourValue>::operator()(const orxonox::ColourValue& __x, const orxonox::ColourValue& __y) const
+ inline bool less<orxonox::ColourValue>::operator()(const orxonox::ColourValue& __x, const orxonox::ColourValue& __y) const
{
if (__x.r == __y.r)
{
Modified: branches/pch/src/util/Convert.h
===================================================================
--- branches/pch/src/util/Convert.h 2009-06-10 20:58:53 UTC (rev 3144)
+++ branches/pch/src/util/Convert.h 2009-06-11 16:22:15 UTC (rev 3145)
@@ -138,7 +138,7 @@
template <class FromType, class ToType>
struct ConverterFallback
{
- static bool convert(ToType* output, const FromType& input)
+ FORCEINLINE static bool convert(ToType* output, const FromType& input)
{
COUT(2) << "Could not convert value of type " << typeid(FromType).name()
<< " to type " << typeid(ToType).name() << std::endl;
@@ -150,7 +150,7 @@
template <class FromType, class ToType>
struct ConverterFallback<FromType*, ToType*>
{
- static bool convert(ToType** output, FromType* const input)
+ FORCEINLINE static bool convert(ToType** output, FromType* const input)
{
ToType* temp = dynamic_cast<ToType*>(input);
if (temp)
@@ -173,7 +173,7 @@
template <class FromType, class ToType>
struct ConverterStringStream
{
- static bool convert(ToType* output, const FromType& input)
+ FORCEINLINE static bool convert(ToType* output, const FromType& input)
{
return orxonox::ConverterFallback<FromType, ToType>::convert(output, input);
}
@@ -187,7 +187,7 @@
namespace fallbackTemplates
{
template <class FromType>
- inline bool operator <<(std::ostream& outstream, const FromType& input)
+ FORCEINLINE bool operator <<(std::ostream& outstream, const FromType& input)
{
std::string temp;
if (orxonox::ConverterFallback<FromType, std::string>::convert(&temp, input))
@@ -204,7 +204,7 @@
template <class FromType>
struct ConverterStringStream<FromType, std::string>
{
- static bool convert(std::string* output, const FromType& input)
+ FORCEINLINE static bool convert(std::string* output, const FromType& input)
{
using namespace fallbackTemplates;
// this operator call only chooses fallbackTemplates::operator<< if there's no other fitting function
@@ -227,7 +227,7 @@
namespace fallbackTemplates
{
template <class ToType>
- inline bool operator >>(std::istream& instream, ToType& output)
+ FORCEINLINE bool operator >>(std::istream& instream, ToType& output)
{
return orxonox::ConverterFallback<std::string, ToType>
::convert(&output, static_cast<std::istringstream&>(instream).str());
@@ -238,7 +238,7 @@
template <class ToType>
struct ConverterStringStream<std::string, ToType>
{
- static bool convert(ToType* output, const std::string& input)
+ FORCEINLINE static bool convert(ToType* output, const std::string& input)
{
using namespace fallbackTemplates;
std::istringstream iss(input);
@@ -261,14 +261,14 @@
// implicit cast not possible, try stringstream conversion next
template <class FromType, class ToType>
- inline bool convertImplicitely(ToType* output, const FromType& input, orxonox::Int2Type<false>)
+ FORCEINLINE bool convertImplicitely(ToType* output, const FromType& input, orxonox::Int2Type<false>)
{
return ConverterStringStream<FromType, ToType>::convert(output, input);
}
// We can cast implicitely
template <class FromType, class ToType>
- inline bool convertImplicitely(ToType* output, const FromType& input, orxonox::Int2Type<true>)
+ FORCEINLINE bool convertImplicitely(ToType* output, const FromType& input, orxonox::Int2Type<true>)
{
(*output) = static_cast<ToType>(input);
return true;
@@ -283,7 +283,7 @@
template <class FromType, class ToType>
struct ConverterExplicit
{
- static bool convert(ToType* output, const FromType& input)
+ FORCEINLINE static bool convert(ToType* output, const FromType& input)
{
// Try implict cast and probe first. If a simple cast is not possible, it will not compile
// We therefore have to out source it into another template function
@@ -305,14 +305,14 @@
'Actual conversion sequence' in this file above.
*/
template <class FromType, class ToType>
- inline bool convertValue(ToType* output, const FromType& input)
+ FORCEINLINE bool convertValue(ToType* output, const FromType& input)
{
return ConverterExplicit<FromType, ToType>::convert(output, input);
}
// For compatibility reasons. The same, but with capital ConvertValue
template<class FromType, class ToType>
- inline bool ConvertValue(ToType* output, const FromType& input)
+ FORCEINLINE bool ConvertValue(ToType* output, const FromType& input)
{
return convertValue(output, input);
}
@@ -330,7 +330,7 @@
A default value that gets written to '*output' if there is no conversion.
*/
template<class FromType, class ToType>
- inline bool convertValue(ToType* output, const FromType& input, const ToType& fallback)
+ FORCEINLINE bool convertValue(ToType* output, const FromType& input, const ToType& fallback)
{
if (convertValue(output, input))
return true;
@@ -343,14 +343,14 @@
// for compatibility reason. (capital 'c' in ConvertValue)
template<class FromType, class ToType>
- inline bool ConvertValue(ToType* output, const FromType& input, const ToType& fallback)
+ FORCEINLINE bool ConvertValue(ToType* output, const FromType& input, const ToType& fallback)
{
return convertValue(output, input, fallback);
}
// Directly returns the converted value, even if the conversion was not successful.
template<class FromType, class ToType>
- inline ToType getConvertedValue(const FromType& input)
+ FORCEINLINE ToType getConvertedValue(const FromType& input)
{
ToType output;
convertValue(&output, input);
@@ -359,7 +359,7 @@
// Directly returns the converted value, but uses the fallback on failure.
template<class FromType, class ToType>
- inline ToType getConvertedValue(const FromType& input, const ToType& fallback)
+ FORCEINLINE ToType getConvertedValue(const FromType& input, const ToType& fallback)
{
ToType output;
convertValue(&output, input, fallback);
@@ -369,7 +369,7 @@
// Like getConvertedValue, but the template argument order is in reverse.
// That means you can call it exactly like static_cast<ToType>(fromTypeValue).
template<class ToType, class FromType>
- inline ToType multi_cast(const FromType& input)
+ FORCEINLINE ToType multi_cast(const FromType& input)
{
ToType output;
convertValue(&output, input);
@@ -378,14 +378,14 @@
// convert to string Shortcut
template <class FromType>
- inline std::string convertToString(FromType value)
+ FORCEINLINE std::string convertToString(FromType value)
{
return getConvertedValue<FromType, std::string>(value);
}
// convert from string Shortcut
template <class ToType>
- inline ToType convertFromString(std::string str)
+ FORCEINLINE ToType convertFromString(std::string str)
{
return getConvertedValue<std::string, ToType>(str);
}
@@ -398,7 +398,7 @@
template <class ToType>
struct ConverterExplicit<const char*, ToType>
{
- static bool convert(ToType* output, const char* input)
+ FORCEINLINE static bool convert(ToType* output, const char* input)
{
return convertValue<std::string, ToType>(output, input);
}
@@ -408,7 +408,7 @@
template <>
struct ConverterExplicit<char, std::string>
{
- static bool convert(std::string* output, const char input)
+ FORCEINLINE static bool convert(std::string* output, const char input)
{
*output = std::string(1, input);
return true;
@@ -417,7 +417,7 @@
template <>
struct ConverterExplicit<unsigned char, std::string>
{
- static bool convert(std::string* output, const unsigned char input)
+ FORCEINLINE static bool convert(std::string* output, const unsigned char input)
{
*output = std::string(1, input);
return true;
@@ -426,7 +426,7 @@
template <>
struct ConverterExplicit<std::string, char>
{
- static bool convert(char* output, const std::string input)
+ FORCEINLINE static bool convert(char* output, const std::string input)
{
if (input != "")
*output = input[0];
@@ -438,7 +438,7 @@
template <>
struct ConverterExplicit<std::string, unsigned char>
{
- static bool convert(unsigned char* output, const std::string input)
+ FORCEINLINE static bool convert(unsigned char* output, const std::string input)
{
if (input != "")
*output = input[0];
@@ -453,7 +453,7 @@
template <>
struct ConverterExplicit<bool, std::string>
{
- static bool convert(std::string* output, const bool& input)
+ FORCEINLINE static bool convert(std::string* output, const bool& input)
{
if (input)
*output = "true";
Modified: branches/pch/src/util/MathConvert.h
===================================================================
--- branches/pch/src/util/MathConvert.h 2009-06-10 20:58:53 UTC (rev 3144)
+++ branches/pch/src/util/MathConvert.h 2009-06-11 16:22:15 UTC (rev 3145)
@@ -49,7 +49,7 @@
template <>
struct ConverterExplicit<orxonox::Vector2, std::string>
{
- static bool convert(std::string* output, const orxonox::Vector2& input)
+ FORCEINLINE static bool convert(std::string* output, const orxonox::Vector2& input)
{
std::ostringstream ostream;
if (ostream << input.x << "," << input.y)
@@ -65,7 +65,7 @@
template <>
struct ConverterExplicit<orxonox::Vector3, std::string>
{
- static bool convert(std::string* output, const orxonox::Vector3& input)
+ FORCEINLINE static bool convert(std::string* output, const orxonox::Vector3& input)
{
std::ostringstream ostream;
if (ostream << input.x << "," << input.y << "," << input.z)
@@ -81,7 +81,7 @@
template <>
struct ConverterExplicit<orxonox::Vector4, std::string>
{
- static bool convert(std::string* output, const orxonox::Vector4& input)
+ FORCEINLINE static bool convert(std::string* output, const orxonox::Vector4& input)
{
std::ostringstream ostream;
if (ostream << input.x << "," << input.y << "," << input.z << "," << input.w)
@@ -97,7 +97,7 @@
template <>
struct ConverterExplicit<orxonox::Quaternion, std::string>
{
- static bool convert(std::string* output, const orxonox::Quaternion& input)
+ FORCEINLINE static bool convert(std::string* output, const orxonox::Quaternion& input)
{
std::ostringstream ostream;
if (ostream << input.w << "," << input.x << "," << input.y << "," << input.z)
@@ -113,7 +113,7 @@
template <>
struct ConverterExplicit<orxonox::ColourValue, std::string>
{
- static bool convert(std::string* output, const orxonox::ColourValue& input)
+ FORCEINLINE static bool convert(std::string* output, const orxonox::ColourValue& input)
{
std::ostringstream ostream;
if (ostream << input.r << "," << input.g << "," << input.b << "," << input.a)
@@ -155,7 +155,7 @@
template <class ToType>
struct ConverterFallback<orxonox::Radian, ToType>
{
- static bool convert(ToType* output, const orxonox::Radian& input)
+ FORCEINLINE static bool convert(ToType* output, const orxonox::Radian& input)
{
return convertValue<Ogre::Real, ToType>(output, input.valueRadians());
}
@@ -165,7 +165,7 @@
template <class ToType>
struct ConverterFallback<orxonox::Degree, ToType>
{
- static bool convert(ToType* output, const orxonox::Degree& input)
+ FORCEINLINE static bool convert(ToType* output, const orxonox::Degree& input)
{
return convertValue<Ogre::Real, ToType>(output, input.valueDegrees());
}
@@ -175,7 +175,7 @@
template <class FromType>
struct ConverterFallback<FromType, orxonox::Radian>
{
- static bool convert(orxonox::Radian* output, const FromType& input)
+ FORCEINLINE static bool convert(orxonox::Radian* output, const FromType& input)
{
float temp;
if (convertValue(&temp, input))
@@ -192,7 +192,7 @@
template <class FromType>
struct ConverterFallback<FromType, orxonox::Degree>
{
- static bool convert(orxonox::Degree* output, const FromType& input)
+ FORCEINLINE static bool convert(orxonox::Degree* output, const FromType& input)
{
float temp;
if (convertValue(&temp, input))
More information about the Orxonox-commit
mailing list