mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
Make better use of C++ rules for implicit generation; allow PointerTo and some mutex impls to be static initialised
This commit is contained in:
parent
0ae87e6781
commit
e60d1e292e
@ -39,6 +39,8 @@ using namespace std;
|
||||
#define OVERRIDE override
|
||||
#define MOVE(x) x
|
||||
#define DEFAULT_CTOR = default
|
||||
#define DEFAULT_DTOR = default
|
||||
#define DELETED = delete
|
||||
|
||||
#define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname)
|
||||
|
||||
@ -166,6 +168,10 @@ template<class T> typename remove_reference<T>::type &&move(T &&t) {
|
||||
# endif
|
||||
# if __has_extension(cxx_defaulted_functions)
|
||||
# define DEFAULT_CTOR = default
|
||||
# define DEFAULT_DTOR = default
|
||||
# endif
|
||||
# if __has_extension(cxx_deleted_functions)
|
||||
# define DELETED = delete
|
||||
# endif
|
||||
#elif defined(__GNUC__) && (__cplusplus >= 201103L) // GCC
|
||||
|
||||
@ -178,6 +184,8 @@ template<class T> typename remove_reference<T>::type &&move(T &&t) {
|
||||
// Starting at GCC 4.4
|
||||
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
|
||||
# define DEFAULT_CTOR = default
|
||||
# define DEFAULT_DTOR = default
|
||||
# define DELETED = delete
|
||||
# endif
|
||||
|
||||
// Starting at GCC 4.6
|
||||
@ -200,7 +208,6 @@ template<class T> typename remove_reference<T>::type &&move(T &&t) {
|
||||
# define FINAL final
|
||||
# define OVERRIDE override
|
||||
# define MOVE(x) move(x)
|
||||
# define DEFAULT_CTOR = default
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1600 // Visual Studio 2010
|
||||
# define NOEXCEPT throw()
|
||||
# define OVERRIDE override
|
||||
@ -209,6 +216,12 @@ template<class T> typename remove_reference<T>::type &&move(T &&t) {
|
||||
# define MOVE(x) move(x)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1800 // Visual Studio 2013
|
||||
# define DEFAULT_CTOR = default
|
||||
# define DEFAULT_DTOR = default
|
||||
# define DELETED = delete
|
||||
#endif
|
||||
|
||||
// Fallbacks if features are not supported
|
||||
#ifndef CONSTEXPR
|
||||
# define CONSTEXPR INLINE
|
||||
@ -228,6 +241,12 @@ template<class T> typename remove_reference<T>::type &&move(T &&t) {
|
||||
#ifndef DEFAULT_CTOR
|
||||
# define DEFAULT_CTOR {}
|
||||
#endif
|
||||
#ifndef DEFAULT_DTOR
|
||||
# define DEFAULT_DTOR {}
|
||||
#endif
|
||||
#ifndef DELETED
|
||||
# define DELETED {assert(false);}
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(LINK_ALL_STATIC) && defined(EXPORT_TEMPLATES)
|
||||
|
@ -14,28 +14,14 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE MutexDummyImpl::
|
||||
MutexDummyImpl() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE MutexDummyImpl::
|
||||
~MutexDummyImpl() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE void MutexDummyImpl::
|
||||
ALWAYS_INLINE void MutexDummyImpl::
|
||||
acquire() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE bool MutexDummyImpl::
|
||||
ALWAYS_INLINE bool MutexDummyImpl::
|
||||
try_acquire() {
|
||||
return true;
|
||||
}
|
||||
@ -43,6 +29,6 @@ try_acquire() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE void MutexDummyImpl::
|
||||
ALWAYS_INLINE void MutexDummyImpl::
|
||||
release() {
|
||||
}
|
||||
|
@ -23,12 +23,16 @@
|
||||
*/
|
||||
class EXPCL_DTOOL MutexDummyImpl {
|
||||
public:
|
||||
INLINE MutexDummyImpl();
|
||||
INLINE ~MutexDummyImpl();
|
||||
CONSTEXPR MutexDummyImpl() DEFAULT_CTOR;
|
||||
|
||||
INLINE void acquire();
|
||||
INLINE bool try_acquire();
|
||||
INLINE void release();
|
||||
private:
|
||||
MutexDummyImpl(const MutexDummyImpl ©) DELETED;
|
||||
MutexDummyImpl &operator = (const MutexDummyImpl ©) DELETED;
|
||||
|
||||
public:
|
||||
ALWAYS_INLINE void acquire();
|
||||
ALWAYS_INLINE bool try_acquire();
|
||||
ALWAYS_INLINE void release();
|
||||
};
|
||||
|
||||
#include "mutexDummyImpl.I"
|
||||
|
@ -14,16 +14,8 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE MutexPosixImpl::
|
||||
MutexPosixImpl() {
|
||||
TAU_PROFILE("MutexPosixImpl::MutexPosixImpl", " ", TAU_USER);
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
// The symbol PTHREAD_MUTEX_DEFAULT isn't always available?
|
||||
// pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT);
|
||||
int result = pthread_mutex_init(&_lock, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
assert(result == 0);
|
||||
CONSTEXPR MutexPosixImpl::
|
||||
MutexPosixImpl() NOEXCEPT : _lock(PTHREAD_MUTEX_INITIALIZER) {
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,6 +70,11 @@ get_posix_lock() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
#ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
||||
CONSTEXPR ReMutexPosixImpl::
|
||||
ReMutexPosixImpl() NOEXCEPT : _lock(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) {
|
||||
}
|
||||
#else
|
||||
INLINE ReMutexPosixImpl::
|
||||
ReMutexPosixImpl() {
|
||||
TAU_PROFILE("ReMutexPosixImpl::ReMutexPosixImpl", " ", TAU_USER);
|
||||
@ -88,6 +85,7 @@ ReMutexPosixImpl() {
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
assert(result == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -28,9 +28,14 @@
|
||||
*/
|
||||
class EXPCL_DTOOL MutexPosixImpl {
|
||||
public:
|
||||
INLINE MutexPosixImpl();
|
||||
CONSTEXPR MutexPosixImpl() NOEXCEPT;
|
||||
INLINE ~MutexPosixImpl();
|
||||
|
||||
private:
|
||||
MutexPosixImpl(const MutexPosixImpl ©) DELETED;
|
||||
MutexPosixImpl &operator = (const MutexPosixImpl ©) DELETED;
|
||||
|
||||
public:
|
||||
INLINE void acquire();
|
||||
INLINE bool try_acquire();
|
||||
INLINE void release();
|
||||
@ -47,9 +52,18 @@ private:
|
||||
*/
|
||||
class EXPCL_DTOOL ReMutexPosixImpl {
|
||||
public:
|
||||
#ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
||||
CONSTEXPR ReMutexPosixImpl() NOEXCEPT;
|
||||
#else
|
||||
INLINE ReMutexPosixImpl();
|
||||
#endif
|
||||
INLINE ~ReMutexPosixImpl();
|
||||
|
||||
private:
|
||||
ReMutexPosixImpl(const ReMutexPosixImpl ©) DELETED;
|
||||
ReMutexPosixImpl &operator = (const ReMutexPosixImpl ©) DELETED;
|
||||
|
||||
public:
|
||||
INLINE void acquire();
|
||||
INLINE bool try_acquire();
|
||||
INLINE void release();
|
||||
|
@ -14,16 +14,8 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE MutexSpinlockImpl::
|
||||
MutexSpinlockImpl() {
|
||||
_lock = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE MutexSpinlockImpl::
|
||||
~MutexSpinlockImpl() {
|
||||
CONSTEXPR MutexSpinlockImpl::
|
||||
MutexSpinlockImpl() : _lock(0) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,9 +29,13 @@
|
||||
*/
|
||||
class EXPCL_DTOOL MutexSpinlockImpl {
|
||||
public:
|
||||
INLINE MutexSpinlockImpl();
|
||||
INLINE ~MutexSpinlockImpl();
|
||||
CONSTEXPR MutexSpinlockImpl();
|
||||
|
||||
private:
|
||||
MutexSpinlockImpl(const MutexSpinlockImpl ©) DELETED;
|
||||
MutexSpinlockImpl &operator = (const MutexSpinlockImpl ©) DELETED;
|
||||
|
||||
public:
|
||||
INLINE void acquire();
|
||||
INLINE bool try_acquire();
|
||||
INLINE void release();
|
||||
|
@ -31,6 +31,11 @@ public:
|
||||
MutexWin32Impl();
|
||||
INLINE ~MutexWin32Impl();
|
||||
|
||||
private:
|
||||
MutexWin32Impl(const MutexWin32Impl ©) DELETED;
|
||||
MutexWin32Impl &operator = (const MutexWin32Impl ©) DELETED;
|
||||
|
||||
public:
|
||||
INLINE void acquire();
|
||||
INLINE bool try_acquire();
|
||||
INLINE void release();
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
template<class Type>
|
||||
INLINE pallocator_single<Type>::
|
||||
pallocator_single(TypeHandle type_handle) throw() :
|
||||
pallocator_single(TypeHandle type_handle) NOEXCEPT :
|
||||
_type_handle(type_handle)
|
||||
{
|
||||
}
|
||||
@ -37,7 +37,7 @@ deallocate(TYPENAME pallocator_single<Type>::pointer p, TYPENAME pallocator_sing
|
||||
|
||||
template<class Type>
|
||||
INLINE pallocator_array<Type>::
|
||||
pallocator_array(TypeHandle type_handle) throw() :
|
||||
pallocator_array(TypeHandle type_handle) NOEXCEPT :
|
||||
_type_handle(type_handle)
|
||||
{
|
||||
}
|
||||
|
@ -52,11 +52,11 @@ public:
|
||||
typedef TYPENAME allocator<Type>::const_reference const_reference;
|
||||
typedef TYPENAME allocator<Type>::size_type size_type;
|
||||
|
||||
INLINE pallocator_single(TypeHandle type_handle) throw();
|
||||
INLINE pallocator_single(TypeHandle type_handle) NOEXCEPT;
|
||||
|
||||
// template member functions in VC++ can only be defined in-class.
|
||||
template<class U>
|
||||
INLINE pallocator_single(const pallocator_single<U> ©) throw() :
|
||||
INLINE pallocator_single(const pallocator_single<U> ©) NOEXCEPT :
|
||||
_type_handle(copy._type_handle) { }
|
||||
|
||||
INLINE pointer allocate(size_type n, allocator<void>::const_pointer hint = 0);
|
||||
@ -80,11 +80,11 @@ public:
|
||||
typedef TYPENAME allocator<Type>::const_reference const_reference;
|
||||
typedef TYPENAME allocator<Type>::size_type size_type;
|
||||
|
||||
INLINE pallocator_array(TypeHandle type_handle = TypeHandle::none()) throw();
|
||||
INLINE pallocator_array(TypeHandle type_handle = TypeHandle::none()) NOEXCEPT;
|
||||
|
||||
// template member functions in VC++ can only be defined in-class.
|
||||
template<class U>
|
||||
INLINE pallocator_array(const pallocator_array<U> ©) throw() :
|
||||
INLINE pallocator_array(const pallocator_array<U> ©) NOEXCEPT :
|
||||
_type_handle(copy._type_handle) { }
|
||||
|
||||
INLINE pointer allocate(size_type n, allocator<void>::const_pointer hint = 0);
|
||||
|
@ -37,7 +37,6 @@ public:
|
||||
typedef pallocator_array<Type> allocator;
|
||||
typedef TYPENAME deque<Type, allocator>::size_type size_type;
|
||||
pdeque(TypeHandle type_handle = pdeque_type_handle) : deque<Type, pallocator_array<Type> >(allocator(type_handle)) { }
|
||||
pdeque(const pdeque<Type> ©) : deque<Type, pallocator_array<Type> >(copy) { }
|
||||
pdeque(size_type n, TypeHandle type_handle = pdeque_type_handle) : deque<Type, pallocator_array<Type> >(n, Type(), allocator(type_handle)) { }
|
||||
pdeque(size_type n, const Type &value, TypeHandle type_handle = pdeque_type_handle) : deque<Type, pallocator_array<Type> >(n, value, allocator(type_handle)) { }
|
||||
};
|
||||
|
@ -38,7 +38,6 @@ public:
|
||||
typedef list<Type, allocator> base_class;
|
||||
typedef TYPENAME base_class::size_type size_type;
|
||||
plist(TypeHandle type_handle = plist_type_handle) : base_class(allocator(type_handle)) { }
|
||||
plist(const plist<Type> ©) : base_class(copy) { }
|
||||
plist(size_type n, TypeHandle type_handle = plist_type_handle) : base_class(n, Type(), allocator(type_handle)) { }
|
||||
plist(size_type n, const Type &value, TypeHandle type_handle = plist_type_handle) : base_class(n, value, allocator(type_handle)) { }
|
||||
|
||||
|
@ -52,7 +52,6 @@ public:
|
||||
typedef map<Key, Value, Compare, allocator> base_class;
|
||||
|
||||
pmap(TypeHandle type_handle = pmap_type_handle) : base_class(Compare(), allocator(type_handle)) { }
|
||||
pmap(const pmap<Key, Value, Compare> ©) : base_class(copy) { }
|
||||
pmap(const Compare &comp, TypeHandle type_handle = pmap_type_handle) : base_class(comp, allocator(type_handle)) { }
|
||||
|
||||
#ifdef USE_TAU
|
||||
@ -118,7 +117,6 @@ class pmultimap : public multimap<Key, Value, Compare, pallocator_single<pair<co
|
||||
public:
|
||||
typedef pallocator_single<pair<const Key, Value> > allocator;
|
||||
pmultimap(TypeHandle type_handle = pmap_type_handle) : multimap<Key, Value, Compare, allocator>(Compare(), allocator(type_handle)) { }
|
||||
pmultimap(const pmultimap<Key, Value, Compare> ©) : multimap<Key, Value, Compare, allocator>(copy) { }
|
||||
pmultimap(const Compare &comp, TypeHandle type_handle = pmap_type_handle) : multimap<Key, Value, Compare, allocator>(comp, allocator(type_handle)) { }
|
||||
};
|
||||
|
||||
@ -132,7 +130,6 @@ template<class Key, class Value, class Compare = method_hash<Key, less<Key> > >
|
||||
class phash_map : public stdext::hash_map<Key, Value, Compare, pallocator_array<pair<const Key, Value> > > {
|
||||
public:
|
||||
phash_map() : stdext::hash_map<Key, Value, Compare, pallocator_array<pair<const Key, Value> > >() { }
|
||||
phash_map(const phash_map<Key, Value, Compare> ©) : stdext::hash_map<Key, Value, Compare, pallocator_array<pair<const Key, Value> > >(copy) { }
|
||||
phash_map(const Compare &comp) : stdext::hash_map<Key, Value, Compare, pallocator_array<pair<const Key, Value> > >(comp) { }
|
||||
};
|
||||
|
||||
@ -145,7 +142,6 @@ template<class Key, class Value, class Compare = method_hash<Key, less<Key> > >
|
||||
class phash_multimap : public stdext::hash_multimap<Key, Value, Compare, pallocator_array<pair<const Key, Value> > > {
|
||||
public:
|
||||
phash_multimap() : stdext::hash_multimap<Key, Value, Compare, pallocator_array<pair<const Key, Value> > >() { }
|
||||
phash_multimap(const phash_multimap<Key, Value, Compare> ©) : stdext::hash_multimap<Key, Value, Compare, pallocator_array<pair<const Key, Value> > >(copy) { }
|
||||
phash_multimap(const Compare &comp) : stdext::hash_multimap<Key, Value, Compare, pallocator_array<pair<const Key, Value> > >(comp) { }
|
||||
};
|
||||
|
||||
|
@ -51,7 +51,6 @@ public:
|
||||
typedef pallocator_single<Key> allocator;
|
||||
typedef set<Key, Compare, allocator> base_class;
|
||||
pset(TypeHandle type_handle = pset_type_handle) : base_class(Compare(), allocator(type_handle)) { }
|
||||
pset(const pset<Key, Compare> ©) : base_class(copy) { }
|
||||
pset(const Compare &comp, TypeHandle type_handle = pset_type_handle) : base_class(comp, type_handle) { }
|
||||
|
||||
#ifdef USE_TAU
|
||||
@ -110,7 +109,6 @@ class pmultiset : public multiset<Key, Compare, pallocator_single<Key> > {
|
||||
public:
|
||||
typedef pallocator_single<Key> allocator;
|
||||
pmultiset(TypeHandle type_handle = pset_type_handle) : multiset<Key, Compare, allocator>(Compare(), allocator(type_handle)) { }
|
||||
pmultiset(const pmultiset<Key, Compare> ©) : multiset<Key, Compare, allocator>(copy) { }
|
||||
pmultiset(const Compare &comp, TypeHandle type_handle = pset_type_handle) : multiset<Key, Compare, allocator>(comp, type_handle) { }
|
||||
};
|
||||
|
||||
@ -124,7 +122,6 @@ template<class Key, class Compare = method_hash<Key, less<Key> > >
|
||||
class phash_set : public stdext::hash_set<Key, Compare, pallocator_array<Key> > {
|
||||
public:
|
||||
phash_set() : stdext::hash_set<Key, Compare, pallocator_array<Key> >() { }
|
||||
phash_set(const phash_set<Key, Compare> ©) : stdext::hash_set<Key, Compare, pallocator_array<Key> >(copy) { }
|
||||
phash_set(const Compare &comp) : stdext::hash_set<Key, Compare, pallocator_array<Key> >(comp) { }
|
||||
};
|
||||
|
||||
@ -137,7 +134,6 @@ template<class Key, class Compare = method_hash<Key, less<Key> > >
|
||||
class phash_multiset : public stdext::hash_multiset<Key, Compare, pallocator_array<Key> > {
|
||||
public:
|
||||
phash_multiset() : stdext::hash_multiset<Key, Compare, pallocator_array<Key> >() { }
|
||||
phash_multiset(const phash_multiset<Key, Compare> ©) : stdext::hash_multiset<Key, Compare, pallocator_array<Key> >(copy) { }
|
||||
phash_multiset(const Compare &comp) : stdext::hash_multiset<Key, Compare, pallocator_array<Key> >(comp) { }
|
||||
};
|
||||
|
||||
|
@ -46,24 +46,9 @@ public:
|
||||
typedef TYPENAME base_class::size_type size_type;
|
||||
|
||||
explicit pvector(TypeHandle type_handle = pvector_type_handle) : base_class(allocator(type_handle)) { }
|
||||
pvector(const pvector<Type> ©) : base_class(copy) { }
|
||||
explicit pvector(size_type n, TypeHandle type_handle = pvector_type_handle) : base_class(n, Type(), allocator(type_handle)) { }
|
||||
explicit pvector(size_type n, const Type &value, TypeHandle type_handle = pvector_type_handle) : base_class(n, value, allocator(type_handle)) { }
|
||||
pvector(const Type *begin, const Type *end, TypeHandle type_handle = pvector_type_handle) : base_class(begin, end, allocator(type_handle)) { }
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
pvector(pvector<Type> &&from) NOEXCEPT : base_class(move(from)) {};
|
||||
|
||||
pvector<Type> &operator =(pvector<Type> &&from) NOEXCEPT {
|
||||
base_class::operator =(move(from));
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
pvector<Type> &operator =(const pvector<Type> ©) {
|
||||
base_class::operator =(copy);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // USE_STL_ALLOCATOR
|
||||
|
@ -11,27 +11,6 @@
|
||||
* @date 2001-05-11
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE TypedObject::
|
||||
TypedObject() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE TypedObject::
|
||||
TypedObject(const TypedObject &) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE void TypedObject::
|
||||
operator = (const TypedObject &) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the internal index number associated with this object's TypeHandle,
|
||||
* a unique number for each different type. This is equivalent to
|
||||
|
@ -47,29 +47,49 @@
|
||||
* What follows are some examples that can be used in new classes that you
|
||||
* create.
|
||||
*
|
||||
* @par In the class definition (.h file): @code public: static TypeHandle
|
||||
* get_class_type() { return _type_handle; } static void init_type() {
|
||||
* <<<BaseClassOne>>>::init_type(); <<<BaseClassTwo>>>::init_type();
|
||||
* <<<BaseClassN>>>::init_type(); register_type(_type_handle,
|
||||
* "<<<ThisClassStringName>>>", <<<BaseClassOne>>>::get_class_type(),
|
||||
* <<<BaseClassTwo>>>::get_class_type(), <<<BaseClassN>>>::get_class_type());
|
||||
* } virtual TypeHandle get_type() const { return get_class_type(); } virtual
|
||||
* TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
* @par In the class definition (.h file):
|
||||
* @code
|
||||
* public:
|
||||
* static TypeHandle get_class_type() {
|
||||
* return _type_handle;
|
||||
* }
|
||||
* static void init_type() {
|
||||
* <<<BaseClassOne>>>::init_type();
|
||||
* <<<BaseClassTwo>>>::init_type();
|
||||
* <<<BaseClassN>>>::init_type();
|
||||
* register_type(_type_handle, "<<<ThisClassStringName>>>",
|
||||
* <<<BaseClassOne>>>::get_class_type(),
|
||||
* <<<BaseClassTwo>>>::get_class_type(),
|
||||
* <<<BaseClassN>>>::get_class_type());
|
||||
* }
|
||||
* virtual TypeHandle get_type() const {
|
||||
* return get_class_type();
|
||||
* }
|
||||
* virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
*
|
||||
* private: static TypeHandle _type_handle; @endcode
|
||||
* private:
|
||||
* static TypeHandle _type_handle;
|
||||
* @endcode
|
||||
*
|
||||
* @par In the class .cxx file: @code TypeHandle
|
||||
* <<<ThisClassStringName>>>::_type_handle; @endcode
|
||||
* @par In the class .cxx file:
|
||||
* @code
|
||||
* TypeHandle <<<ThisClassStringName>>>::_type_handle;
|
||||
* @endcode
|
||||
*
|
||||
* @par In the class config_<<<PackageName>>>.cxx file: @code
|
||||
* ConfigureFn(config_<<<PackageName>>>) { <<<ClassOne>>>::init_type();
|
||||
* <<<ClassTwo>>>::init_type(); <<<ClassN>>>::init_type(); } @endcode
|
||||
* @par In the class config_<<<PackageName>>>.cxx file:
|
||||
* @code
|
||||
* ConfigureFn(config_<<<PackageName>>>) {
|
||||
* <<<ClassOne>>>::init_type();
|
||||
* <<<ClassTwo>>>::init_type();
|
||||
* <<<ClassN>>>::init_type();
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
class EXPCL_DTOOL TypedObject : public MemoryBase {
|
||||
public:
|
||||
INLINE TypedObject();
|
||||
INLINE TypedObject(const TypedObject ©);
|
||||
INLINE void operator = (const TypedObject ©);
|
||||
INLINE TypedObject() DEFAULT_CTOR;
|
||||
INLINE TypedObject(const TypedObject ©) DEFAULT_CTOR;
|
||||
INLINE TypedObject &operator = (const TypedObject ©) DEFAULT_CTOR;
|
||||
|
||||
PUBLISHED:
|
||||
// A virtual destructor is just a good idea.
|
||||
|
@ -25,6 +25,9 @@ class EXPCL_DTOOLCONFIG StreamWrapperBase {
|
||||
protected:
|
||||
INLINE StreamWrapperBase();
|
||||
|
||||
private:
|
||||
INLINE StreamWrapperBase(const StreamWrapperBase ©) DELETED;
|
||||
|
||||
PUBLISHED:
|
||||
INLINE void acquire();
|
||||
INLINE void release();
|
||||
|
@ -30,36 +30,13 @@ DatagramIterator(const Datagram &datagram, size_t offset) :
|
||||
nassertv(_current_index <= _datagram->get_length());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE DatagramIterator::
|
||||
DatagramIterator(const DatagramIterator ©) :
|
||||
_datagram(copy._datagram),
|
||||
_current_index(copy._current_index) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE void DatagramIterator::
|
||||
operator = (const DatagramIterator ©) {
|
||||
_datagram = copy._datagram;
|
||||
_current_index = copy._current_index;
|
||||
}
|
||||
/**
|
||||
* direct Assignment to a Datagram
|
||||
*/
|
||||
INLINE void DatagramIterator::assign(Datagram &datagram, size_t offset)
|
||||
{
|
||||
_datagram =&datagram;
|
||||
_current_index = offset;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE DatagramIterator::
|
||||
~DatagramIterator() {
|
||||
INLINE void DatagramIterator::
|
||||
assign(Datagram &datagram, size_t offset) {
|
||||
_datagram = &datagram;
|
||||
_current_index = offset;
|
||||
}
|
||||
|
||||
// Various ways to get data and increment the iterator... Cut-and-paste-orama
|
||||
|
@ -31,9 +31,6 @@ public:
|
||||
PUBLISHED:
|
||||
INLINE DatagramIterator();
|
||||
INLINE DatagramIterator(const Datagram &datagram, size_t offset = 0);
|
||||
INLINE DatagramIterator(const DatagramIterator ©);
|
||||
INLINE void operator = (const DatagramIterator ©);
|
||||
INLINE ~DatagramIterator();
|
||||
|
||||
INLINE bool get_bool();
|
||||
INLINE int8_t get_int8();
|
||||
|
@ -19,13 +19,6 @@ HashGeneratorBase() {
|
||||
_hash = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE HashGeneratorBase::
|
||||
~HashGeneratorBase() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash number generated.
|
||||
*/
|
||||
|
@ -30,7 +30,6 @@
|
||||
class EXPCL_PANDAEXPRESS HashGeneratorBase {
|
||||
public:
|
||||
INLINE HashGeneratorBase();
|
||||
INLINE ~HashGeneratorBase();
|
||||
|
||||
INLINE size_t get_hash() const;
|
||||
|
||||
|
@ -20,35 +20,6 @@ Namable(const string &initial_name) :
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE Namable::
|
||||
Namable(const Namable ©) :
|
||||
_name(copy._name)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE Namable &Namable::
|
||||
operator = (const Namable &other) {
|
||||
_name = other._name;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE Namable &Namable::
|
||||
operator = (Namable &&other) NOEXCEPT {
|
||||
_name = MOVE(other._name);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -26,12 +26,6 @@
|
||||
class EXPCL_PANDAEXPRESS Namable : public MemoryBase {
|
||||
PUBLISHED:
|
||||
INLINE explicit Namable(const string &initial_name = "");
|
||||
INLINE Namable(const Namable ©);
|
||||
INLINE Namable &operator = (const Namable &other);
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
INLINE Namable &operator = (Namable &&other) NOEXCEPT;
|
||||
#endif
|
||||
|
||||
INLINE void set_name(const string &name);
|
||||
INLINE void clear_name();
|
||||
|
@ -33,16 +33,6 @@ NodePointerTo(const NodePointerTo<T> ©) :
|
||||
}
|
||||
#endif // CPPPARSER
|
||||
|
||||
#ifndef CPPPARSER
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE NodePointerTo<T>::
|
||||
~NodePointerTo() {
|
||||
}
|
||||
#endif // CPPPARSER
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
#ifndef CPPPARSER
|
||||
/**
|
||||
@ -177,16 +167,6 @@ NodeConstPointerTo(const NodeConstPointerTo<T> ©) :
|
||||
}
|
||||
#endif // CPPPARSER
|
||||
|
||||
#ifndef CPPPARSER
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE NodeConstPointerTo<T>::
|
||||
~NodeConstPointerTo() {
|
||||
}
|
||||
#endif // CPPPARSER
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
#ifndef CPPPARSER
|
||||
/**
|
||||
|
@ -31,7 +31,6 @@ public:
|
||||
typedef TYPENAME NodePointerToBase<T>::To To;
|
||||
INLINE NodePointerTo(To *ptr = (To *)NULL);
|
||||
INLINE NodePointerTo(const NodePointerTo<T> ©);
|
||||
INLINE ~NodePointerTo();
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
INLINE NodePointerTo(NodePointerTo<T> &&from) NOEXCEPT;
|
||||
@ -66,7 +65,6 @@ public:
|
||||
INLINE NodeConstPointerTo(const To *ptr = (const To *)NULL);
|
||||
INLINE NodeConstPointerTo(const NodePointerTo<T> ©);
|
||||
INLINE NodeConstPointerTo(const NodeConstPointerTo<T> ©);
|
||||
INLINE ~NodeConstPointerTo();
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
INLINE NodeConstPointerTo(NodePointerTo<T> &&from) NOEXCEPT;
|
||||
|
@ -33,36 +33,6 @@ ordered_vector(const Compare &compare, TypeHandle type_handle) :
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class Key, class Compare, class Vector>
|
||||
INLINE ordered_vector<Key, Compare, Vector>::
|
||||
ordered_vector(const ordered_vector<Key, Compare, Vector> ©) :
|
||||
_compare(copy._compare),
|
||||
_vector(copy._vector)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class Key, class Compare, class Vector>
|
||||
INLINE ordered_vector<Key, Compare, Vector> &ordered_vector<Key, Compare, Vector>::
|
||||
operator = (const ordered_vector<Key, Compare, Vector> ©) {
|
||||
_compare = copy._compare;
|
||||
_vector = copy._vector;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class Key, class Compare, class Vector>
|
||||
INLINE ordered_vector<Key, Compare, Vector>::
|
||||
~ordered_vector() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the iterator that marks the first element in the ordered vector.
|
||||
*/
|
||||
@ -636,26 +606,6 @@ ov_set(const Compare &compare, TypeHandle type_handle) :
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class Key, class Compare, class Vector>
|
||||
INLINE ov_set<Key, Compare, Vector>::
|
||||
ov_set(const ov_set<Key, Compare, Vector> ©) :
|
||||
ordered_vector<Key, Compare, Vector>(copy)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class Key, class Compare, class Vector>
|
||||
INLINE ov_set<Key, Compare, Vector> &ov_set<Key, Compare, Vector>::
|
||||
operator = (const ov_set<Key, Compare, Vector> ©) {
|
||||
ordered_vector<Key, Compare, Vector>::operator = (copy);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps to insert_unique().
|
||||
*/
|
||||
@ -713,26 +663,6 @@ ov_multiset(const Compare &compare, TypeHandle type_handle) :
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class Key, class Compare, class Vector>
|
||||
INLINE ov_multiset<Key, Compare, Vector>::
|
||||
ov_multiset(const ov_multiset<Key, Compare, Vector> ©) :
|
||||
ordered_vector<Key, Compare, Vector>(copy)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class Key, class Compare, class Vector>
|
||||
INLINE ov_multiset<Key, Compare, Vector> &ov_multiset<Key, Compare, Vector>::
|
||||
operator = (const ov_multiset<Key, Compare, Vector> ©) {
|
||||
ordered_vector<Key, Compare, Vector>::operator = (copy);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps to insert_nonunique().
|
||||
*/
|
||||
|
@ -135,9 +135,6 @@ public:
|
||||
INLINE ordered_vector(TypeHandle type_handle = ov_set_type_handle);
|
||||
INLINE ordered_vector(const Compare &compare,
|
||||
TypeHandle type_handle = ov_set_type_handle);
|
||||
INLINE ordered_vector(const ordered_vector<Key, Compare, Vector> ©);
|
||||
INLINE ordered_vector<Key, Compare, Vector> &operator = (const ordered_vector<Key, Compare, Vector> ©);
|
||||
INLINE ~ordered_vector();
|
||||
|
||||
// Iterator access.
|
||||
INLINE ITERATOR begin();
|
||||
@ -265,8 +262,6 @@ public:
|
||||
INLINE ov_set(TypeHandle type_handle = ov_set_type_handle);
|
||||
INLINE ov_set(const Compare &compare,
|
||||
TypeHandle type_handle = ov_set_type_handle);
|
||||
INLINE ov_set(const ov_set<Key, Compare, Vector> ©);
|
||||
INLINE ov_set<Key, Compare, Vector> &operator = (const ov_set<Key, Compare, Vector> ©);
|
||||
|
||||
INLINE ITERATOR insert(ITERATOR position, const VALUE_TYPE &key0);
|
||||
INLINE pair<ITERATOR, bool> insert(const VALUE_TYPE &key0);
|
||||
@ -288,8 +283,6 @@ public:
|
||||
INLINE ov_multiset(TypeHandle type_handle = ov_set_type_handle);
|
||||
INLINE ov_multiset(const Compare &compare,
|
||||
TypeHandle type_handle = ov_set_type_handle);
|
||||
INLINE ov_multiset(const ov_multiset<Key, Compare, Vector> ©);
|
||||
INLINE ov_multiset<Key, Compare, Vector> &operator = (const ov_multiset<Key, Compare, Vector> ©);
|
||||
|
||||
INLINE ITERATOR insert(ITERATOR position, const VALUE_TYPE &key);
|
||||
INLINE ITERATOR insert(const VALUE_TYPE &key);
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
template<class T>
|
||||
ALWAYS_INLINE PointerTo<T>::
|
||||
PointerTo(To *ptr) : PointerToBase<T>(ptr) {
|
||||
PointerTo(To *ptr) NOEXCEPT : PointerToBase<T>(ptr) {
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,16 +55,8 @@ operator = (PointerTo<T> &&from) NOEXCEPT {
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE PointerTo<T>::
|
||||
~PointerTo() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE TYPENAME PointerTo<T>::To &PointerTo<T>::
|
||||
operator *() const {
|
||||
CONSTEXPR TYPENAME PointerTo<T>::To &PointerTo<T>::
|
||||
operator *() const NOEXCEPT {
|
||||
return *((To *)(this->_void_ptr));
|
||||
}
|
||||
|
||||
@ -72,8 +64,8 @@ operator *() const {
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE TYPENAME PointerTo<T>::To *PointerTo<T>::
|
||||
operator -> () const {
|
||||
CONSTEXPR TYPENAME PointerTo<T>::To *PointerTo<T>::
|
||||
operator -> () const NOEXCEPT {
|
||||
return (To *)(this->_void_ptr);
|
||||
}
|
||||
|
||||
@ -84,8 +76,8 @@ operator -> () const {
|
||||
* goes because either will be correct.
|
||||
*/
|
||||
template<class T>
|
||||
INLINE PointerTo<T>::
|
||||
operator T * () const {
|
||||
CONSTEXPR PointerTo<T>::
|
||||
operator T * () const NOEXCEPT {
|
||||
return (To *)(this->_void_ptr);
|
||||
}
|
||||
|
||||
@ -107,8 +99,8 @@ cheat() {
|
||||
* compiler problems, particularly for implicit upcasts.
|
||||
*/
|
||||
template<class T>
|
||||
INLINE TYPENAME PointerTo<T>::To *PointerTo<T>::
|
||||
p() const {
|
||||
CONSTEXPR TYPENAME PointerTo<T>::To *PointerTo<T>::
|
||||
p() const NOEXCEPT {
|
||||
return (To *)(this->_void_ptr);
|
||||
}
|
||||
|
||||
@ -137,7 +129,7 @@ operator = (const PointerTo<T> ©) {
|
||||
*/
|
||||
template<class T>
|
||||
ALWAYS_INLINE ConstPointerTo<T>::
|
||||
ConstPointerTo(const TYPENAME ConstPointerTo<T>::To *ptr) :
|
||||
ConstPointerTo(const TYPENAME ConstPointerTo<T>::To *ptr) NOEXCEPT :
|
||||
PointerToBase<T>((TYPENAME ConstPointerTo<T>::To *)ptr)
|
||||
{
|
||||
}
|
||||
@ -152,14 +144,6 @@ ConstPointerTo(const PointerTo<T> ©) :
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE ConstPointerTo<T>::
|
||||
~ConstPointerTo() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -216,8 +200,8 @@ operator = (ConstPointerTo<T> &&from) NOEXCEPT {
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE const TYPENAME ConstPointerTo<T>::To &ConstPointerTo<T>::
|
||||
operator *() const {
|
||||
CONSTEXPR const TYPENAME ConstPointerTo<T>::To &ConstPointerTo<T>::
|
||||
operator *() const NOEXCEPT {
|
||||
return *((To *)(this->_void_ptr));
|
||||
}
|
||||
|
||||
@ -225,8 +209,8 @@ operator *() const {
|
||||
*
|
||||
*/
|
||||
template<class T>
|
||||
INLINE const TYPENAME ConstPointerTo<T>::To *ConstPointerTo<T>::
|
||||
operator -> () const {
|
||||
CONSTEXPR const TYPENAME ConstPointerTo<T>::To *ConstPointerTo<T>::
|
||||
operator -> () const NOEXCEPT {
|
||||
return (To *)(this->_void_ptr);
|
||||
}
|
||||
|
||||
@ -237,8 +221,8 @@ operator -> () const {
|
||||
* don't care which way it goes because either will be correct.
|
||||
*/
|
||||
template<class T>
|
||||
INLINE ConstPointerTo<T>::
|
||||
operator const T * () const {
|
||||
CONSTEXPR ConstPointerTo<T>::
|
||||
operator const T * () const NOEXCEPT {
|
||||
return (To *)(this->_void_ptr);
|
||||
}
|
||||
|
||||
@ -260,8 +244,8 @@ cheat() {
|
||||
* around compiler problems, particularly for implicit upcasts.
|
||||
*/
|
||||
template<class T>
|
||||
INLINE const TYPENAME ConstPointerTo<T>::To *ConstPointerTo<T>::
|
||||
p() const {
|
||||
CONSTEXPR const TYPENAME ConstPointerTo<T>::To *ConstPointerTo<T>::
|
||||
p() const NOEXCEPT {
|
||||
return (To *)(this->_void_ptr);
|
||||
}
|
||||
|
||||
|
@ -14,35 +14,47 @@
|
||||
#ifndef POINTERTO_H
|
||||
#define POINTERTO_H
|
||||
|
||||
/*
|
||||
/**
|
||||
* This file defines the classes PointerTo and ConstPointerTo (and their
|
||||
* abbreviations, PT and CPT). These should be used in place of traditional
|
||||
* C-style pointers wherever implicit reference counting is desired. The
|
||||
* syntax is: instead of: PointerTo<MyClass> p;
|
||||
* MyClass *p; PT(MyClass) p; ConstPointerTo<MyClass> p; const MyClass
|
||||
* *p; CPT(MyClass) p; PointerTo and ConstPointerTo will automatically
|
||||
* increment the object's reference count while the pointer is kept. When the
|
||||
* PointerTo object is reassigned or goes out of scope, the reference count is
|
||||
* automatically decremented. If the reference count reaches zero, the object
|
||||
* is freed. Note that const PointerTo<MyClass> is different from
|
||||
* C-style pointers wherever implicit reference counting is desired.
|
||||
*
|
||||
* The syntax is: instead of:
|
||||
*
|
||||
* PointerTo<MyClass> p; MyClass *p;
|
||||
* PT(MyClass) p;
|
||||
*
|
||||
* ConstPointerTo<MyClass> p; const MyClass *p;
|
||||
* CPT(MyClass) p;
|
||||
*
|
||||
* PointerTo and ConstPointerTo will automatically increment the object's
|
||||
* reference count while the pointer is kept. When the PointerTo object is
|
||||
* reassigned or goes out of scope, the reference count is automatically
|
||||
* decremented. If the reference count reaches zero, the object is freed.
|
||||
*
|
||||
* Note that const PointerTo<MyClass> is different from
|
||||
* ConstPointerTo<MyClass>. A const PointerTo may not reassign its pointer,
|
||||
* but it may still modify the contents at that address. On the other hand, a
|
||||
* ConstPointerTo may reassign its pointer at will, but may not modify the
|
||||
* contents. It is like the difference between (MyClass * const) and (const
|
||||
* MyClass *). In order to use PointerTo, it is necessary that the thing
|
||||
* pointed to--MyClass in the above example--either inherits from
|
||||
* ReferenceCount, or is a proxy built with RefCountProxy or RefCountObj (see
|
||||
* referenceCount.h). However, also see PointerToArray, which does not have
|
||||
* this restriction. It is crucial that the PointerTo object is only used to
|
||||
* refer to objects allocated from the free store, for which delete is a
|
||||
* sensible thing to do. If you assign a PointerTo to an automatic variable
|
||||
* (allocated from the stack, for instance), bad things will certainly happen
|
||||
* when the reference count reaches zero and it tries to delete it. It's also
|
||||
* important to remember that, as always, a virtual destructor is required if
|
||||
* you plan to support polymorphism. That is, if you define a PointerTo to
|
||||
* some base type, and assign to it instances of a class derived from that
|
||||
* base class, the base class must have a virtual destructor in order to
|
||||
* properly destruct the derived object when it is deleted.
|
||||
* contents. It is like the difference between (MyClass * const) and
|
||||
* (const MyClass *).
|
||||
*
|
||||
* In order to use PointerTo, it is necessary that the thing pointed to
|
||||
* --MyClass in the above example--either inherits from ReferenceCount, or is
|
||||
* a proxy built with RefCountProxy or RefCountObj (see referenceCount.h).
|
||||
* However, also see PointerToArray, which does not have this restriction.
|
||||
*
|
||||
* It is crucial that the PointerTo object is only used to refer to objects
|
||||
* allocated from the free store, for which delete is a sensible thing to do.
|
||||
* If you assign a PointerTo to an automatic variable (allocated from the
|
||||
* stack, for instance), bad things will certainly happen when the reference
|
||||
* count reaches zero and it tries to delete it.
|
||||
*
|
||||
* It's also important to remember that, as always, a virtual destructor is
|
||||
* required if you plan to support polymorphism. That is, if you define a
|
||||
* PointerTo to some base type, and assign to it instances of a class derived
|
||||
* from that base class, the base class must have a virtual destructor in
|
||||
* order to properly destruct the derived object when it is deleted.
|
||||
*/
|
||||
|
||||
#include "pandabase.h"
|
||||
@ -58,10 +70,9 @@ class PointerTo : public PointerToBase<T> {
|
||||
public:
|
||||
typedef TYPENAME PointerToBase<T>::To To;
|
||||
PUBLISHED:
|
||||
ALWAYS_INLINE PointerTo() DEFAULT_CTOR;
|
||||
ALWAYS_INLINE PointerTo(To *ptr);
|
||||
ALWAYS_INLINE CONSTEXPR PointerTo() NOEXCEPT DEFAULT_CTOR;
|
||||
ALWAYS_INLINE PointerTo(To *ptr) NOEXCEPT;
|
||||
INLINE PointerTo(const PointerTo<T> ©);
|
||||
INLINE ~PointerTo();
|
||||
|
||||
public:
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
@ -69,10 +80,10 @@ public:
|
||||
INLINE PointerTo<T> &operator = (PointerTo<T> &&from) NOEXCEPT;
|
||||
#endif
|
||||
|
||||
INLINE To &operator *() const;
|
||||
INLINE To *operator -> () const;
|
||||
CONSTEXPR To &operator *() const NOEXCEPT;
|
||||
CONSTEXPR To *operator -> () const NOEXCEPT;
|
||||
// MSVC.NET 2005 insists that we use T *, and not To *, here.
|
||||
INLINE operator T *() const;
|
||||
CONSTEXPR operator T *() const NOEXCEPT;
|
||||
|
||||
INLINE T *&cheat();
|
||||
|
||||
@ -89,7 +100,7 @@ PUBLISHED:
|
||||
// the DCAST macro defined in typedObject.h instead, e.g. DCAST(MyType,
|
||||
// ptr). This provides a clean downcast that doesn't require .p() or any
|
||||
// double-casting, and it can be run-time checked for correctness.
|
||||
INLINE To *p() const;
|
||||
CONSTEXPR To *p() const NOEXCEPT;
|
||||
|
||||
INLINE PointerTo<T> &operator = (To *ptr);
|
||||
INLINE PointerTo<T> &operator = (const PointerTo<T> ©);
|
||||
@ -98,8 +109,10 @@ PUBLISHED:
|
||||
// anyway just to help out interrogate (which doesn't seem to want to
|
||||
// automatically export the PointerToBase class). When this works again in
|
||||
// interrogate, we can remove these.
|
||||
INLINE bool is_null() const { return PointerToBase<T>::is_null(); }
|
||||
INLINE void clear() { PointerToBase<T>::clear(); }
|
||||
#ifdef CPPPARSER
|
||||
INLINE bool is_null() const;
|
||||
INLINE void clear();
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -120,11 +133,10 @@ class ConstPointerTo : public PointerToBase<T> {
|
||||
public:
|
||||
typedef TYPENAME PointerToBase<T>::To To;
|
||||
PUBLISHED:
|
||||
ALWAYS_INLINE ConstPointerTo() DEFAULT_CTOR;
|
||||
ALWAYS_INLINE ConstPointerTo(const To *ptr);
|
||||
ALWAYS_INLINE CONSTEXPR ConstPointerTo() NOEXCEPT DEFAULT_CTOR;
|
||||
ALWAYS_INLINE ConstPointerTo(const To *ptr) NOEXCEPT;
|
||||
INLINE ConstPointerTo(const PointerTo<T> ©);
|
||||
INLINE ConstPointerTo(const ConstPointerTo<T> ©);
|
||||
INLINE ~ConstPointerTo();
|
||||
|
||||
public:
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
@ -134,14 +146,14 @@ public:
|
||||
INLINE ConstPointerTo<T> &operator = (ConstPointerTo<T> &&from) NOEXCEPT;
|
||||
#endif
|
||||
|
||||
INLINE const To &operator *() const;
|
||||
INLINE const To *operator -> () const;
|
||||
INLINE operator const T *() const;
|
||||
CONSTEXPR const To &operator *() const NOEXCEPT;
|
||||
CONSTEXPR const To *operator -> () const NOEXCEPT;
|
||||
CONSTEXPR operator const T *() const NOEXCEPT;
|
||||
|
||||
INLINE const T *&cheat();
|
||||
|
||||
PUBLISHED:
|
||||
INLINE const To *p() const;
|
||||
CONSTEXPR const To *p() const NOEXCEPT;
|
||||
|
||||
INLINE ConstPointerTo<T> &operator = (const To *ptr);
|
||||
INLINE ConstPointerTo<T> &operator = (const PointerTo<T> ©);
|
||||
@ -151,7 +163,9 @@ PUBLISHED:
|
||||
// anyway just to help out interrogate (which doesn't seem to want to
|
||||
// automatically export the PointerToBase class). When this works again in
|
||||
// interrogate, we can remove this.
|
||||
INLINE void clear() { PointerToBase<T>::clear(); }
|
||||
#ifdef CPPPARSER
|
||||
INLINE void clear();
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -68,6 +68,17 @@ PointerToArray(const PointerToArray<Element> ©) :
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a PointerToArray by copying existing elements.
|
||||
*/
|
||||
template<class Element>
|
||||
INLINE PointerToArray<Element>::
|
||||
PointerToArray(const Element *begin, const Element *end, TypeHandle type_handle) :
|
||||
PointerToArrayBase<Element>(new ReferenceCountedVector<Element>(begin, end, type_handle)),
|
||||
_type_handle(type_handle)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
/**
|
||||
*
|
||||
@ -627,6 +638,17 @@ ConstPointerToArray(TypeHandle type_handle) :
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a ConstPointerToArray by copying existing elements.
|
||||
*/
|
||||
template<class Element>
|
||||
INLINE ConstPointerToArray<Element>::
|
||||
ConstPointerToArray(const Element *begin, const Element *end, TypeHandle type_handle) :
|
||||
PointerToArrayBase<Element>(new ReferenceCountedVector<Element>(begin, end, type_handle)),
|
||||
_type_handle(type_handle)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -134,6 +134,7 @@ public:
|
||||
INLINE PointerToArray(TypeHandle type_handle = get_type_handle(Element));
|
||||
INLINE static PointerToArray<Element> empty_array(size_type n, TypeHandle type_handle = get_type_handle(Element));
|
||||
INLINE PointerToArray(size_type n, const Element &value, TypeHandle type_handle = get_type_handle(Element));
|
||||
INLINE PointerToArray(const Element *begin, const Element *end, TypeHandle type_handle = get_type_handle(Element));
|
||||
INLINE PointerToArray(const PointerToArray<Element> ©);
|
||||
|
||||
#ifdef USE_MOVE_SEMANTICS
|
||||
@ -289,6 +290,7 @@ PUBLISHED:
|
||||
typedef TYPENAME pvector<Element>::size_type size_type;
|
||||
|
||||
INLINE ConstPointerToArray(TypeHandle type_handle = get_type_handle(Element));
|
||||
INLINE ConstPointerToArray(const Element *begin, const Element *end, TypeHandle type_handle = get_type_handle(Element));
|
||||
INLINE ConstPointerToArray(const PointerToArray<Element> ©);
|
||||
INLINE ConstPointerToArray(const ConstPointerToArray<Element> ©);
|
||||
|
||||
|
@ -19,17 +19,6 @@ INLINE ReferenceCountedVector<Element>::
|
||||
ReferenceCountedVector(TypeHandle type_handle) : pvector<Element>(type_handle) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class Element>
|
||||
INLINE ReferenceCountedVector<Element>::
|
||||
ReferenceCountedVector(const ReferenceCountedVector<Element> ©) :
|
||||
NodeReferenceCount(copy),
|
||||
pvector<Element>(copy)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of initial_size elements.
|
||||
*/
|
||||
@ -41,11 +30,13 @@ ReferenceCountedVector(TYPENAME ReferenceCountedVector<Element>::size_type initi
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates an array with all elements from begin up to but not including end.
|
||||
*/
|
||||
template<class Element>
|
||||
INLINE ReferenceCountedVector<Element>::
|
||||
~ReferenceCountedVector() {
|
||||
ReferenceCountedVector(const Element *begin, const Element *end, TypeHandle type_handle) :
|
||||
pvector<Element>(begin, end, type_handle)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,9 +41,8 @@ public:
|
||||
typedef TYPENAME pvector<Element>::size_type size_type;
|
||||
|
||||
INLINE ReferenceCountedVector(TypeHandle type_handle);
|
||||
INLINE ReferenceCountedVector(const ReferenceCountedVector<Element> ©);
|
||||
INLINE ReferenceCountedVector(size_type initial_size, TypeHandle type_handle);
|
||||
INLINE ~ReferenceCountedVector();
|
||||
INLINE ReferenceCountedVector(const Element *begin, const Element *end, TypeHandle type_handle);
|
||||
ALLOC_DELETED_CHAIN(ReferenceCountedVector<Element>);
|
||||
|
||||
INLINE size_type size() const;
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
typedef T To;
|
||||
|
||||
protected:
|
||||
ALWAYS_INLINE PointerToBase() DEFAULT_CTOR;
|
||||
ALWAYS_INLINE CONSTEXPR PointerToBase() NOEXCEPT DEFAULT_CTOR;
|
||||
INLINE PointerToBase(To *ptr);
|
||||
INLINE PointerToBase(const PointerToBase<T> ©);
|
||||
INLINE ~PointerToBase();
|
||||
|
@ -14,34 +14,25 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE PointerToVoid::
|
||||
PointerToVoid() {
|
||||
_void_ptr = (void *)NULL;
|
||||
INLINE CONSTEXPR PointerToVoid::
|
||||
PointerToVoid() NOEXCEPT : _void_ptr(nullptr) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE PointerToVoid::
|
||||
~PointerToVoid() {
|
||||
nassertv(_void_ptr == (void *)NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't use this constructor.
|
||||
*/
|
||||
INLINE PointerToVoid::
|
||||
PointerToVoid(const PointerToVoid &) {
|
||||
nassertv(false);
|
||||
}
|
||||
//INLINE PointerToVoid::
|
||||
//~PointerToVoid() {
|
||||
// nassertv(_void_ptr == nullptr);
|
||||
//}
|
||||
|
||||
/**
|
||||
* Returns true if the PointerTo is a NULL pointer, false otherwise. (Direct
|
||||
* comparison to a NULL pointer also works.)
|
||||
*/
|
||||
ALWAYS_INLINE bool PointerToVoid::
|
||||
ALWAYS_INLINE CONSTEXPR bool PointerToVoid::
|
||||
is_null() const {
|
||||
return (_void_ptr == (void *)NULL);
|
||||
return _void_ptr == nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,14 +32,14 @@
|
||||
*/
|
||||
class EXPCL_PANDAEXPRESS PointerToVoid : public MemoryBase {
|
||||
protected:
|
||||
INLINE PointerToVoid();
|
||||
INLINE ~PointerToVoid();
|
||||
ALWAYS_INLINE CONSTEXPR PointerToVoid() NOEXCEPT;
|
||||
//INLINE ~PointerToVoid();
|
||||
|
||||
private:
|
||||
INLINE PointerToVoid(const PointerToVoid ©);
|
||||
PointerToVoid(const PointerToVoid ©) DELETED;
|
||||
|
||||
PUBLISHED:
|
||||
ALWAYS_INLINE bool is_null() const;
|
||||
ALWAYS_INLINE CONSTEXPR bool is_null() const;
|
||||
INLINE size_t get_hash() const;
|
||||
|
||||
public:
|
||||
|
@ -15,16 +15,9 @@
|
||||
*
|
||||
*/
|
||||
INLINE WeakPointerToVoid::
|
||||
WeakPointerToVoid() {
|
||||
_ptr_was_deleted = false;
|
||||
_callback = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE WeakPointerToVoid::
|
||||
~WeakPointerToVoid() {
|
||||
WeakPointerToVoid() :
|
||||
_ptr_was_deleted(false),
|
||||
_callback(NULL) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,7 +25,6 @@
|
||||
class EXPCL_PANDAEXPRESS WeakPointerToVoid : public PointerToVoid {
|
||||
protected:
|
||||
INLINE WeakPointerToVoid();
|
||||
INLINE ~WeakPointerToVoid();
|
||||
|
||||
public:
|
||||
INLINE void mark_deleted();
|
||||
|
@ -30,26 +30,6 @@ BitArray(WordType init_value) {
|
||||
_highest_bits = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE BitArray::
|
||||
BitArray(const BitArray ©) :
|
||||
_array(copy._array),
|
||||
_highest_bits(copy._highest_bits)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE BitArray &BitArray::
|
||||
operator = (const BitArray ©) {
|
||||
_array = copy._array;
|
||||
_highest_bits = copy._highest_bits;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a BitArray with an infinite array of bits, all on.
|
||||
*/
|
||||
@ -98,13 +78,6 @@ range(int low_bit, int size) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE BitArray::
|
||||
~BitArray() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if there is a maximum number of bits that may be stored in
|
||||
* this structure, false otherwise. If this returns true, the number may be
|
||||
|
@ -46,8 +46,6 @@ PUBLISHED:
|
||||
|
||||
INLINE BitArray();
|
||||
INLINE BitArray(WordType init_value);
|
||||
INLINE BitArray(const BitArray ©);
|
||||
INLINE BitArray &operator = (const BitArray ©);
|
||||
BitArray(const SparseArray &from);
|
||||
|
||||
INLINE static BitArray all_on();
|
||||
@ -56,8 +54,6 @@ PUBLISHED:
|
||||
INLINE static BitArray bit(int index);
|
||||
INLINE static BitArray range(int low_bit, int size);
|
||||
|
||||
INLINE ~BitArray();
|
||||
|
||||
CONSTEXPR static bool has_max_num_bits();
|
||||
CONSTEXPR static int get_max_num_bits();
|
||||
|
||||
|
@ -34,26 +34,6 @@ BitMask(WordType init_value) :
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class WType, int nbits>
|
||||
INLINE BitMask<WType, nbits>::
|
||||
BitMask(const BitMask<WType, nbits> ©) :
|
||||
_word(copy._word)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class WType, int nbits>
|
||||
INLINE BitMask<WType, nbits> &BitMask<WType, nbits>::
|
||||
operator = (const BitMask<WType, nbits> ©) {
|
||||
_word = copy._word;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a BitMask whose bits are all on.
|
||||
*/
|
||||
@ -121,14 +101,6 @@ range(int low_bit, int size) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
template<class WType, int nbits>
|
||||
INLINE BitMask<WType, nbits>::
|
||||
~BitMask() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if there is a maximum number of bits that may be stored in
|
||||
* this structure, false otherwise. If this returns true, the number may be
|
||||
|
@ -38,8 +38,6 @@ PUBLISHED:
|
||||
|
||||
INLINE BitMask();
|
||||
INLINE BitMask(WordType init_value);
|
||||
INLINE BitMask(const BitMask<WType, nbits> ©);
|
||||
INLINE BitMask<WType, nbits> &operator = (const BitMask<WType, nbits> ©);
|
||||
|
||||
INLINE static BitMask<WType, nbits> all_on();
|
||||
INLINE static BitMask<WType, nbits> all_off();
|
||||
@ -47,8 +45,6 @@ PUBLISHED:
|
||||
INLINE static BitMask<WType, nbits> bit(int index);
|
||||
INLINE static BitMask<WType, nbits> range(int low_bit, int size);
|
||||
|
||||
INLINE ~BitMask();
|
||||
|
||||
CONSTEXPR static bool has_max_num_bits();
|
||||
CONSTEXPR static int get_max_num_bits();
|
||||
|
||||
|
@ -19,13 +19,6 @@ CONSTEXPR ButtonHandle::
|
||||
ButtonHandle(int index) : _index(index) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE ButtonHandle::
|
||||
ButtonHandle(const ButtonHandle ©) : _index(copy._index) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -31,7 +31,6 @@ PUBLISHED:
|
||||
// previously by another static initializer!
|
||||
INLINE ButtonHandle() DEFAULT_CTOR;
|
||||
CONSTEXPR ButtonHandle(int index);
|
||||
INLINE ButtonHandle(const ButtonHandle ©);
|
||||
ButtonHandle(const string &name);
|
||||
|
||||
PUBLISHED:
|
||||
|
@ -14,6 +14,7 @@
|
||||
#ifndef ITERATOR_TYPES_H
|
||||
#define ITERATOR_TYPES_H
|
||||
|
||||
#include "dtoolbase.h"
|
||||
|
||||
/**
|
||||
* This is an iterator adaptor that converts any iterator that returns a pair
|
||||
@ -25,9 +26,8 @@ class first_of_pair_iterator : public pair_iterator {
|
||||
public:
|
||||
typedef TYPENAME pair_iterator::value_type::first_type value_type;
|
||||
|
||||
first_of_pair_iterator() { }
|
||||
first_of_pair_iterator() DEFAULT_CTOR;
|
||||
first_of_pair_iterator(const pair_iterator &init) : pair_iterator(init) { }
|
||||
first_of_pair_iterator(const first_of_pair_iterator<pair_iterator> ©) : pair_iterator(copy) { }
|
||||
|
||||
value_type operator *() {
|
||||
return pair_iterator::operator *().first;
|
||||
@ -44,9 +44,8 @@ class second_of_pair_iterator : public pair_iterator {
|
||||
public:
|
||||
typedef TYPENAME pair_iterator::value_type::second_type value_type;
|
||||
|
||||
second_of_pair_iterator() { }
|
||||
second_of_pair_iterator() DEFAULT_CTOR;
|
||||
second_of_pair_iterator(const pair_iterator &init) : pair_iterator(init) { }
|
||||
second_of_pair_iterator(const second_of_pair_iterator<pair_iterator> ©) : pair_iterator(copy) { }
|
||||
|
||||
value_type operator *() {
|
||||
return pair_iterator::operator *().second;
|
||||
@ -62,9 +61,8 @@ class typecast_iterator : public base_iterator {
|
||||
public:
|
||||
typedef new_type value_type;
|
||||
|
||||
typecast_iterator() { }
|
||||
typecast_iterator() DEFAULT_CTOR;
|
||||
typecast_iterator(const base_iterator &init) : base_iterator(init) { }
|
||||
typecast_iterator(const typecast_iterator<base_iterator, new_type> ©) : base_iterator(copy) { }
|
||||
|
||||
value_type operator *() {
|
||||
return (new_type)base_iterator::operator *();
|
||||
|
@ -18,26 +18,6 @@ INLINE SparseArray::
|
||||
SparseArray() : _inverse(false) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE SparseArray::
|
||||
SparseArray(const SparseArray ©) :
|
||||
_subranges(copy._subranges),
|
||||
_inverse(copy._inverse)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE SparseArray &SparseArray::
|
||||
operator = (const SparseArray ©) {
|
||||
_subranges = copy._subranges;
|
||||
_inverse = copy._inverse;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SparseArray with an infinite array of bits, all on.
|
||||
*/
|
||||
@ -62,7 +42,9 @@ all_off() {
|
||||
INLINE SparseArray SparseArray::
|
||||
lower_on(int on_bits) {
|
||||
SparseArray result;
|
||||
result.set_range(0, on_bits);
|
||||
if (on_bits > 0) {
|
||||
result._subranges.push_back(Subrange(0, on_bits));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -86,13 +68,6 @@ range(int low_bit, int size) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE SparseArray::
|
||||
~SparseArray() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if there is a maximum number of bits that may be stored in
|
||||
* this structure, false otherwise. If this returns true, the number may be
|
||||
|
@ -42,8 +42,6 @@ class DatagramIterator;
|
||||
class EXPCL_PANDA_PUTIL SparseArray {
|
||||
PUBLISHED:
|
||||
INLINE SparseArray();
|
||||
INLINE SparseArray(const SparseArray ©);
|
||||
INLINE SparseArray &operator = (const SparseArray ©);
|
||||
SparseArray(const BitArray &from);
|
||||
|
||||
INLINE static SparseArray all_on();
|
||||
@ -52,8 +50,6 @@ PUBLISHED:
|
||||
INLINE static SparseArray bit(int index);
|
||||
INLINE static SparseArray range(int low_bit, int size);
|
||||
|
||||
INLINE ~SparseArray();
|
||||
|
||||
INLINE static bool has_max_num_bits();
|
||||
INLINE static int get_max_num_bits();
|
||||
|
||||
|
@ -30,22 +30,6 @@ WritableParam(const WritableParam ©) :
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE WritableParam::
|
||||
~WritableParam() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE void WritableParam::
|
||||
operator = (const WritableParam &) {
|
||||
// The assignment operator cannot be used for this class.
|
||||
nassertv(false);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -36,11 +36,10 @@ private:
|
||||
public:
|
||||
INLINE WritableParam(const Datagram &datagram);
|
||||
INLINE WritableParam(const WritableParam &other);
|
||||
INLINE ~WritableParam();
|
||||
|
||||
private:
|
||||
// The assignment operator cannot be used for this class.
|
||||
INLINE void operator = (const WritableParam &other);
|
||||
INLINE void operator = (const WritableParam &other) DELETED;
|
||||
|
||||
public:
|
||||
virtual TypeHandle get_type() const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user