1 /* 2 * Copyright 2018 Rockchip Electronics Co. LTD 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 * Author: martin.cheng@rock-chips.com 17 * Date: 2018/12/26 18 */ 19 20 #ifndef SRC_RT_MEDIA_INCLUDE_RTOBJECT_H_ 21 #define SRC_RT_MEDIA_INCLUDE_RTOBJECT_H_ 22 23 #include <typeinfo> 24 #include "rt_type.h" // NOLINT 25 26 class RTMemTrace; 27 class RTObject { 28 public: 29 virtual const char* getName() = 0; 30 virtual void summary(INT32 fd) = 0; 31 virtual RT_BOOL equals(RTObject* ptr); 32 33 /** return hash-code of object. 34 * 35 * @return hash-code of object 36 * 37 * Best Practice: use jvmHashCode(typeid(this).name()) as hash code. 38 */ 39 virtual UINT32 hashCode(); 40 41 public: 42 /** calculate hash-code of object name. 43 * 44 * @return hash-code of object name 45 * 46 * using hash function of the java virtual machine default. 47 */ 48 static UINT32 jvmHashCode(const char* name); 49 50 protected: 51 void trace(const char* name, void* ptr, UINT32 size); // Called in Constructor 52 void untrace(const char* name, void* ptr); // Called in Destructor 53 54 private: 55 static RTMemTrace* mObjTraces; 56 }; 57 58 #endif // SRC_RT_MEDIA_INCLUDE_RTOBJECT_H_ 59