⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 macros.h

📁 粗慥集成算法集合 ,并有详细的文档资料和测试数据处
💻 H
字号:
//-------------------------------------------------------------------
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Revisions.....:
//===================================================================

#ifndef __MACROS_H__
#define __MACROS_H__

#include <copyright.h>

//-------------------------------------------------------------------
// Name..........: DECLAREID
// Author........: Aleksander 豩rn
// Date..........: 960307
// Description...: Macro for declaring identifiers.
// Revisions.....:
//===================================================================

#define DECLAREID(id)                                               \
extern const Id id;

//-------------------------------------------------------------------
// Name..........: IMPLEMENTID
// Author........: Aleksander 豩rn
// Date..........: 960307
// Description...: Macro for implementing identifiers.
// Revisions.....:
//===================================================================

#define IMPLEMENTID(id, classname, description)                     \
const Id id = IdHolder::Register(classname, description);

//-------------------------------------------------------------------
// Name..........: DECLAREIDMETHODS
// Author........: Aleksander 豩rn
// Date..........: 960307
// Description...: Macro for declaring identifier methods.
// Revisions.....:
//===================================================================

#define DECLAREIDMETHODS()                                          \
virtual bool IsA(Id id) const;                                      \
virtual Id   GetId() const;

//-------------------------------------------------------------------
// Name..........: IMPLEMENTIDMETHODS
// Author........: Aleksander 豩rn
// Date..........: 960307
// Description...: Macro for implementing identifier methods.
// Revisions.....:
//===================================================================

#define IMPLEMENTIDMETHODS(classname, id, basename)                 \
bool                                                                \
classname##::IsA(Id x) const {                                      \
	return (x == id || basename##::IsA(x));                           \
}                                                                   \
	                                                                  \
Id                                                                  \
classname##::GetId() const {                                        \
	return id;                                                        \
}

//-------------------------------------------------------------------
// Name..........: Installation macros
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Macros for installing prototype objects.
//                 This macro hides the fact that dialogs are not
//                 relevant outside the ROSETTA GUI, and enables one
//                 keep the installation call interface uniform.
// Comments......:
// Revisions.....:
//===================================================================

#define INSTALLSTRUCTURE(classname)                   ObjectManager::Install(classname);

#if defined(_ROSGUI)
	#define INSTALLALGORITHM(classname, dialogname)     ObjectManager::Install(classname, dialogname);
#else
	#define INSTALLALGORITHM(classname, dialogname)     ObjectManager::Install(classname);
#endif

//-------------------------------------------------------------------
// Name..........: Container macros
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Macros to (i) save keystrokes and (ii) to make any
//                 later changes in containers less painful, e.g., if
//                 we want to use something else than STL.
//
// Comments......: The macro Set(type) cannot currently be defined due
//                 to a naming conflict with RSES. Resolve later.
//
//                 If an STL alternative to vectors is desired, the
//                 Array template can be used instead.
//
// Revisions.....:
//===================================================================

#define STLList(type)                                 std::list<type >
#define STLMap(type1, type2)                          std::map<type1, type2, std::less<type1 > >
#define STLPair(type1, type2)                         std::pair<type1, type2 >
#define STLSet(type)                                  std::set<type, std::less<type > >
#define STLVector(type)                               std::vector<type >
#define STLHashMap(type1, type2)                      std::hash_map<type1, type2 >
#define STLHashSet(type)                              std::hash_set<type >

#define List(type)                                    STLList(type)
#define Map(type1, type2)                             STLMap(type1, type2)
#define Pair(type1, type2)                            STLPair(type1, type2)
#define Vector(type)                                  STLVector(type)
#define HashMap(type1, type2)                         STLHashMap(type1, type2)
#define HashSet(type)                                 STLHashSet(type)

//-------------------------------------------------------------------
// Name..........: Casting macros
// Author........: Aleksander 豩rn
// Date..........: 960511
// Description...: Macros to ease porting to "old" compilers that do
//                 not yet support the new C++-style casts.
// Comments......: MSVC++ 4.2 seems a lot more fussy than MSVC++ 4.0
//                 about the correct usage of the new casts.  For
//                 instance, MSVC++ 4.0 allows dynamic_cast to
//                 also cast away constness, while MSVC++ 4.2 insists
//                 on such constructs being composed of both a
//                 dynamic_cast and a const_cast.
// Revisions.....:
//===================================================================

#if defined(_OLDCASTS)
	#define const_cast(type, expression)                ((type) (expression))
	#define dynamic_cast(type, expression)              ((type) (expression))
	#define static_cast(type, expression)               ((type) (expression))
	#define reinterpret_cast(type, expression)          ((type) (expression))
#else
	#define const_cast(type, expression)                const_cast<type >(expression)
	#define dynamic_cast(type, expression)              dynamic_cast<type >(expression)
	#define static_cast(type, expression)               static_cast<type >(expression)
	#define reinterpret_cast(type, expression)          reinterpret_cast<type >(expression)
#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -