diff --git a/CMakeLists.txt b/CMakeLists.txt index eb77559..faec0f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ macro(cm_example_project sub_folder project_name) - target_link_libraries(${project_name} PRIVATE CMCore CMPlatform CMUtil) + target_link_libraries(${project_name} PRIVATE CMCore CMPlatform CMUtil tsl::robin_map) if(UNIX) target_link_libraries(${project_name} PRIVATE dl) @@ -11,6 +11,12 @@ set_debugger_directory(${project_name} ${CMAKE_CURRENT_SOURCE_DIR}) target_sources(${project_name} PRIVATE ${CM_MANIFEST}) + + if(MSVC) + target_sources(${project_name} INTERFACE + ${CM_NATVIS}) + endif() + ENDIF() set_property(TARGET ${project_name} PROPERTY FOLDER "CM/Examples/${sub_folder}") @@ -21,7 +27,10 @@ macro(set_example_project_folder sub_folder project_name) endmacro() #################################################################################################### +add_executable(DebugObject debug/DebugObject.cpp) +CM_EXAMPLE_PROJECT("Debug" DebugObject) +#################################################################################################### add_executable(TypeSizeof datatype/TypeSizeof.cpp) CM_EXAMPLE_PROJECT("DataType" TypeSizeof) @@ -32,7 +41,7 @@ add_executable(HalfFloatTest datatype/HalfFloatTest.cpp) cm_example_project("DataType" HalfFloatTest) add_executable(SplitStringTest datatype/SplitStringTest.cpp) -cm_example_project("DataType" SplitStringTest) +cm_example_project("DataType" SplitStringTest ${CM_NATVIS}) add_executable(StrChrTest datatype/strchr_test.cpp) cm_example_project("DataType" StrChrTest) @@ -59,6 +68,10 @@ cm_example_project("DataType" ConstStringSetTest) add_executable(IDNameTest datatype/IDNameTest.cpp) cm_example_project("DataType" IDNameTest) +#################################################################################################### + +add_executable(OutputEpsilon math/OutputEpsilon.cpp) +CM_EXAMPLE_PROJECT("Math" OutputEpsilon) add_executable(TransformBenchmark math/TransformBenchmark.cpp) CM_EXAMPLE_PROJECT("Math" TransformBenchmark) diff --git a/debug/DebugObject.cpp b/debug/DebugObject.cpp new file mode 100644 index 0000000..5ae69e0 --- /dev/null +++ b/debug/DebugObject.cpp @@ -0,0 +1,80 @@ +#include + +#include + +using namespace hgl; + +class DebugObject:public Object +{ + HGL_OBJECT_CLASS_BODY(DebugObject) + +public: + + void Initailize() + { + std::cout<<"DebugObject::Initailize("< + +HGL_DEFINE_DEFAULT_OBJECT_MANAGER(DebugObject); + +#include + +int main() +{ + SafePtr obj1=HGL_NEW_OBJECT(DebugObject); + + HGL_DEFINE_OBJECT(DebugObject,obj2); //等于上一行 + +// DebugObject *obj3=new DebugObject(); //编译不过(构造函数被定义为私有) + + obj1.Release(); + + //delete obj2; //编译不过,SafePtr<>不能被delete + + if(obj1.IsValid()) + { + std::cerr<<"[ERROR] obj1 IsValid() error!"<GetSerialNumber(); + + SafePtr obj2_indirect=GetObjectBySerial(obj2_sn); //直接根据序列号获取对象 + + if(!obj2_indirect.IsValid()) + { + std::cerr<<"[ERROR] obj2_indirect isn't valid!"< +#include + +using namespace std; +using namespace hgl; + +int main(int,char **) +{ + std::cout<<"float: "<