| 
									
										
										
										
											2018-11-19 20:11:02 +08:00
										 |  |  | // Copyright (c) 2016-2018 Easy2D - Nomango
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
					
						
							|  |  |  | // of this software and associated documentation files (the "Software"), to deal
 | 
					
						
							|  |  |  | // in the Software without restriction, including without limitation the rights
 | 
					
						
							|  |  |  | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
					
						
							|  |  |  | // copies of the Software, and to permit persons to whom the Software is
 | 
					
						
							|  |  |  | // furnished to do so, subject to the following conditions:
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // The above copyright notice and this permission notice shall be included in
 | 
					
						
							|  |  |  | // all copies or substantial portions of the Software.
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
					
						
							|  |  |  | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
					
						
							|  |  |  | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
					
						
							|  |  |  | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
					
						
							|  |  |  | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
					
						
							|  |  |  | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
					
						
							|  |  |  | // THE SOFTWARE.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | #include "RefCounter.hpp"
 | 
					
						
							| 
									
										
										
										
											2019-01-21 21:24:45 +08:00
										 |  |  | #include "helper.hpp"
 | 
					
						
							| 
									
										
										
										
											2018-11-19 20:11:02 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace easy2d | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-11-23 14:55:03 +08:00
										 |  |  | 	class Object | 
					
						
							| 
									
										
										
										
											2018-11-19 20:11:02 +08:00
										 |  |  | 		: public RefCounter | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 	public: | 
					
						
							| 
									
										
										
										
											2018-11-23 14:55:03 +08:00
										 |  |  | 		Object(); | 
					
						
							| 
									
										
										
										
											2018-11-19 20:11:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-23 14:55:03 +08:00
										 |  |  | 		virtual ~Object(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		void* GetUserData() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		void SetUserData(void* data); | 
					
						
							| 
									
										
										
										
											2018-11-19 20:11:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-07 23:54:19 +08:00
										 |  |  | 		void SetName(String const& name); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		inline String GetName() const { if (name_) return *name_; return String(); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		inline bool IsName(String const& name) const { return (name_ && (*name_ == name)); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-19 20:11:02 +08:00
										 |  |  | 		static void StartTracingLeaks(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		static void StopTracingLeaks(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-21 21:24:45 +08:00
										 |  |  | 		static Array<Object*> const& __GetTracingObjects(); | 
					
						
							| 
									
										
										
										
											2018-11-19 20:11:02 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	protected: | 
					
						
							| 
									
										
										
										
											2018-11-23 14:55:03 +08:00
										 |  |  | 		static void __AddObjectToTracingList(Object*); | 
					
						
							| 
									
										
										
										
											2018-11-19 20:11:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-23 14:55:03 +08:00
										 |  |  | 		static void __RemoveObjectFromTracingList(Object*); | 
					
						
							| 
									
										
										
										
											2018-11-19 20:11:02 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	private: | 
					
						
							|  |  |  | 		bool tracing_leak_; | 
					
						
							| 
									
										
										
										
											2018-11-23 14:55:03 +08:00
										 |  |  | 		void* user_data_; | 
					
						
							| 
									
										
										
										
											2019-02-07 23:54:19 +08:00
										 |  |  | 		String* name_; | 
					
						
							| 
									
										
										
										
											2018-11-19 20:11:02 +08:00
										 |  |  | 	}; | 
					
						
							|  |  |  | } |