Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
c4d7d5af
Commit
c4d7d5af
authored
Dec 22, 2011
by
LM
Browse files
Merge branch 'v10release' of github.com:pixhawk/qgroundcontrol into v10release
parents
35bbb3f9
e013c9d2
Changes
628
Hide whitespace changes
Inline
Side-by-side
lib/mac64/include/OpenThreads/Atomic
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenThreads library, Copyright (C) 2008 The Open Thread Group
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef _OPENTHREADS_ATOMIC_
#define _OPENTHREADS_ATOMIC_
#include
<OpenThreads/Config>
#include
<OpenThreads/Exports>
#if defined(_OPENTHREADS_ATOMIC_USE_BSD_ATOMIC)
# include <libkern/OSAtomic.h>
# define _OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES
#elif defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS) && defined(__i386__)
# define _OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES
#elif defined(_OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
# define _OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
# include <atomic.h>
# include "Mutex"
# include "ScopedLock"
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
# include "Mutex"
# include "ScopedLock"
#endif
#if defined(_OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES)
#define _OPENTHREADS_ATOMIC_INLINE
#else
#define _OPENTHREADS_ATOMIC_INLINE inline
#endif
namespace
OpenThreads
{
/**
* @class Atomic
* @brief This class provides an atomic increment and decrement operation.
*/
class
OPENTHREAD_EXPORT_DIRECTIVE
Atomic
{
public:
Atomic
(
unsigned
value
=
0
)
:
_value
(
value
)
{
}
_OPENTHREADS_ATOMIC_INLINE
unsigned
operator
++
();
_OPENTHREADS_ATOMIC_INLINE
unsigned
operator
--
();
_OPENTHREADS_ATOMIC_INLINE
unsigned
AND
(
unsigned
value
);
_OPENTHREADS_ATOMIC_INLINE
unsigned
OR
(
unsigned
value
);
_OPENTHREADS_ATOMIC_INLINE
unsigned
XOR
(
unsigned
value
);
_OPENTHREADS_ATOMIC_INLINE
unsigned
exchange
(
unsigned
value
=
0
);
_OPENTHREADS_ATOMIC_INLINE
operator
unsigned
()
const
;
private:
Atomic
(
const
Atomic
&
);
Atomic
&
operator
=
(
const
Atomic
&
);
#if defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
mutable
Mutex
_mutex
;
#endif
#if defined(_OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
volatile
long
_value
;
#elif defined(_OPENTHREADS_ATOMIC_USE_BSD_ATOMIC)
volatile
int32_t
_value
;
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
volatile
uint_t
_value
;
mutable
Mutex
_mutex
;
// needed for xor
#else
volatile
unsigned
_value
;
#endif
};
/**
* @class AtomicPtr
* @brief This class provides an atomic pointer assignment using cas operations.
*/
class
OPENTHREAD_EXPORT_DIRECTIVE
AtomicPtr
{
public:
AtomicPtr
(
void
*
ptr
=
0
)
:
_ptr
(
ptr
)
{
}
~
AtomicPtr
()
{
_ptr
=
0
;
}
// assigns a new pointer
_OPENTHREADS_ATOMIC_INLINE
bool
assign
(
void
*
ptrNew
,
const
void
*
const
ptrOld
);
_OPENTHREADS_ATOMIC_INLINE
void
*
get
()
const
;
private:
AtomicPtr
(
const
AtomicPtr
&
);
AtomicPtr
&
operator
=
(
const
AtomicPtr
&
);
#if defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
mutable
Mutex
_mutex
;
#endif
void
*
volatile
_ptr
;
};
#if !defined(_OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES)
_OPENTHREADS_ATOMIC_INLINE
unsigned
Atomic
::
operator
++
()
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
return
__sync_add_and_fetch
(
&
_value
,
1
);
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
return
__add_and_fetch
(
&
_value
,
1
);
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
return
atomic_inc_uint_nv
(
&
_value
);
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock
<
Mutex
>
lock
(
_mutex
);
return
++
_value
;
#else
return
++
_value
;
#endif
}
_OPENTHREADS_ATOMIC_INLINE
unsigned
Atomic
::
operator
--
()
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
return
__sync_sub_and_fetch
(
&
_value
,
1
);
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
return
__sub_and_fetch
(
&
_value
,
1
);
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
return
atomic_dec_uint_nv
(
&
_value
);
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock
<
Mutex
>
lock
(
_mutex
);
return
--
_value
;
#else
return
--
_value
;
#endif
}
_OPENTHREADS_ATOMIC_INLINE
unsigned
Atomic
::
AND
(
unsigned
value
)
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
return
__sync_fetch_and_and
(
&
_value
,
value
);
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
return
__and_and_fetch
(
&
_value
,
value
);
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
return
atomic_and_uint_nv
(
&
_value
,
value
);
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock
<
Mutex
>
lock
(
_mutex
);
_value
&=
value
;
return
_value
;
#else
_value
&=
value
;
return
_value
;
#endif
}
_OPENTHREADS_ATOMIC_INLINE
unsigned
Atomic
::
OR
(
unsigned
value
)
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
return
__sync_fetch_and_or
(
&
_value
,
value
);
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
return
__or_and_fetch
(
&
_value
,
value
);
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
return
atomic_or_uint_nv
(
&
_value
,
value
);
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock
<
Mutex
>
lock
(
_mutex
);
_value
|=
value
;
return
_value
;
#else
_value
|=
value
;
return
_value
;
#endif
}
_OPENTHREADS_ATOMIC_INLINE
unsigned
Atomic
::
XOR
(
unsigned
value
)
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
return
__sync_fetch_and_xor
(
&
_value
,
value
);
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
return
__xor_and_fetch
(
&
_value
,
value
);
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
ScopedLock
<
Mutex
>
lock
(
_mutex
);
_value
^=
value
;
return
_value
;
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock
<
Mutex
>
lock
(
_mutex
);
_value
^=
value
;
return
_value
;
#else
_value
^=
value
;
return
_value
;
#endif
}
_OPENTHREADS_ATOMIC_INLINE
unsigned
Atomic
::
exchange
(
unsigned
value
)
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
return
__sync_lock_test_and_set
(
&
_value
,
value
);
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
return
__compare_and_swap
(
&
_value
,
_value
,
value
);
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
return
atomic_cas_uint
(
&
_value
,
_value
,
value
);
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock
<
Mutex
>
lock
(
_mutex
);
unsigned
oldval
=
_value
;
_value
=
value
;
return
oldval
;
#else
unsigned
oldval
=
_value
;
_value
=
value
;
return
oldval
;
#endif
}
_OPENTHREADS_ATOMIC_INLINE
Atomic
::
operator
unsigned
()
const
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
__sync_synchronize
();
return
_value
;
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
__synchronize
();
return
_value
;
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
membar_consumer
();
// Hmm, do we need???
return
_value
;
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock
<
Mutex
>
lock
(
_mutex
);
return
_value
;
#else
return
_value
;
#endif
}
_OPENTHREADS_ATOMIC_INLINE
bool
AtomicPtr
::
assign
(
void
*
ptrNew
,
const
void
*
const
ptrOld
)
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
return
__sync_bool_compare_and_swap
(
&
_ptr
,
ptrOld
,
ptrNew
);
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
return
__compare_and_swap
((
unsigned
long
*
)
&
_ptr
,
(
unsigned
long
)
ptrOld
,
(
unsigned
long
)
ptrNew
);
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
return
ptrOld
==
atomic_cas_ptr
(
&
_ptr
,
const_cast
<
void
*>
(
ptrOld
),
ptrNew
);
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock
<
Mutex
>
lock
(
_mutex
);
if
(
_ptr
!=
ptrOld
)
return
false
;
_ptr
=
ptrNew
;
return
true
;
#else
if
(
_ptr
!=
ptrOld
)
return
false
;
_ptr
=
ptrNew
;
return
true
;
#endif
}
_OPENTHREADS_ATOMIC_INLINE
void
*
AtomicPtr
::
get
()
const
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
__sync_synchronize
();
return
_ptr
;
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
__synchronize
();
return
_ptr
;
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
membar_consumer
();
// Hmm, do we need???
return
_ptr
;
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock
<
Mutex
>
lock
(
_mutex
);
return
_ptr
;
#else
return
_ptr
;
#endif
}
#endif // !defined(_OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES)
}
#endif // _OPENTHREADS_ATOMIC_
lib/mac64/include/OpenThreads/Barrier
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
//
// Barrier - C++ barrier class
// ~~~~~~~
//
#ifndef _OPENTHREADS_BARRIER_
#define _OPENTHREADS_BARRIER_
#include
<OpenThreads/Exports>
namespace
OpenThreads
{
/**
* @class Barrier
* @brief This class provides an object-oriented thread barrier interface
*
* @warning It is unwise to use the construct "Barrier barrier" in the
* global namespace on sgi's. The object "barrier"
* will confilict with the c-library sproc function "barrier" and
* unpredictable results may occur. You have been warned.
*/
class
OPENTHREAD_EXPORT_DIRECTIVE
Barrier
{
public:
/**
* Constructor
*/
Barrier
(
int
numThreads
=
0
);
/**
* Destructor
*/
virtual
~
Barrier
();
/**
* Reset the barrier to it's original state.
*/
virtual
void
reset
();
/**
* Block until numThreads threads have entered the barrier.
*/
virtual
void
block
(
unsigned
int
numThreads
=
0
);
/**
* Release the barrier, now.
*/
virtual
void
release
();
/**
* Return the number of threads currently blocked in the barrier,
* Return -1 if error.
*/
virtual
int
numThreadsCurrentlyBlocked
();
void
invalidate
();
private:
/**
* Private copy constructor, to prevent tampering.
*/
Barrier
(
const
Barrier
&
/*b*/
)
{};
/**
* Private copy assignment, to prevent tampering.
*/
Barrier
&
operator
=
(
const
Barrier
&
/*b*/
)
{
return
*
(
this
);};
/**
* Implementation-specific private data.
*/
void
*
_prvData
;
bool
_valid
;
};
}
#endif // !_OPENTHREADS_BARRIER_
lib/mac64/include/OpenThreads/Block
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenThreads - Copyright (C) 1998-2007 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef _OPENTHREADS_BLOCK_
#define _OPENTHREADS_BLOCK_
#include
<OpenThreads/Thread>
#include
<OpenThreads/Barrier>
#include
<OpenThreads/Condition>
#include
<OpenThreads/ScopedLock>
namespace
OpenThreads
{
/** Block is a block that can be used to halt a thread that is waiting another thread to release it.*/
class
Block
{
public:
Block
()
:
_released
(
false
)
{}
~
Block
()
{
release
();
}
inline
bool
block
()
{
ScopedLock
<
OpenThreads
::
Mutex
>
mutlock
(
_mut
);
if
(
!
_released
)
{
return
_cond
.
wait
(
&
_mut
)
==
0
;
}
else
{
return
true
;
}
}
inline
bool
block
(
unsigned
long
timeout
)
{
ScopedLock
<
OpenThreads
::
Mutex
>
mutlock
(
_mut
);
if
(
!
_released
)
{
return
_cond
.
wait
(
&
_mut
,
timeout
)
==
0
;
}
else
{
return
true
;
}
}
inline
void
release
()
{
ScopedLock
<
OpenThreads
::
Mutex
>
mutlock
(
_mut
);
if
(
!
_released
)
{
_released
=
true
;
_cond
.
broadcast
();
}
}
inline
void
reset
()
{
ScopedLock
<
OpenThreads
::
Mutex
>
mutlock
(
_mut
);
_released
=
false
;
}
inline
void
set
(
bool
doRelease
)
{
if
(
doRelease
!=
_released
)
{
if
(
doRelease
)
release
();
else
reset
();
}
}
protected:
Mutex
_mut
;
Condition
_cond
;
bool
_released
;
private:
Block
(
const
Block
&
)
{}
};
/** BlockCount is a block that can be used to halt a thread that is waiting for a specified number of operations to be completed.*/
class
BlockCount
{
public:
BlockCount
(
unsigned
int
blockCount
)
:
_blockCount
(
blockCount
),
_currentCount
(
0
)
{}
~
BlockCount
()
{
_blockCount
=
0
;
release
();
}
inline
void
completed
()
{
OpenThreads
::
ScopedLock
<
OpenThreads
::
Mutex
>
mutlock
(
_mut
);
if
(
_currentCount
>
0
)
{
--
_currentCount
;
if
(
_currentCount
==
0
)
{
// osg::notify(osg::NOTICE)<<"Released"<<std::endl;
_cond
.
broadcast
();
}
}
}
inline
void
block
()
{
OpenThreads
::
ScopedLock
<
OpenThreads
::
Mutex
>
mutlock
(
_mut
);
if
(
_currentCount
)
_cond
.
wait
(
&
_mut
);
}
inline
void
reset
()
{
OpenThreads
::
ScopedLock
<
OpenThreads
::
Mutex
>
mutlock
(
_mut
);
if
(
_currentCount
!=
_blockCount
)
{
if
(
_blockCount
==
0
)
_cond
.
broadcast
();
_currentCount
=
_blockCount
;
}
}
inline
void
release
()
{
OpenThreads
::
ScopedLock
<
OpenThreads
::
Mutex
>
mutlock
(
_mut
);
if
(
_currentCount
)
{
_currentCount
=
0
;
_cond
.
broadcast
();
}
}
inline
void
setBlockCount
(
unsigned
int
blockCount
)
{
_blockCount
=
blockCount
;
}
inline
unsigned
int
getBlockCount
()
const
{
return
_blockCount
;
}
inline
unsigned
int
getCurrentCount
()
const
{
return
_currentCount
;
}
protected:
OpenThreads
::
Mutex
_mut
;
OpenThreads
::
Condition
_cond
;
unsigned
int
_blockCount
;
unsigned
int
_currentCount
;
private:
BlockCount
(
const
BlockCount
&
)
{}
};
}
#endif
lib/mac64/include/OpenThreads/Condition
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
//
// Condition - C++ condition class
// ~~~~~~~~~
//
#ifndef _OPENTHREADS_CONDITION_
#define _OPENTHREADS_CONDITION_
#include
<OpenThreads/Exports>
#include
<OpenThreads/Mutex>
namespace
OpenThreads
{
/**
* @class Condition
* @brief This class provides an object-oriented thread condition interface.
*/
class
OPENTHREAD_EXPORT_DIRECTIVE
Condition
{
public:
/**
* Constructor
*/
Condition
();
/**
* Destructor
*/
virtual
~
Condition
();
/**
* Wait on a mutex.
*/
virtual
int
wait
(
Mutex
*
mutex
);
/**
* Wait on a mutex for a given amount of time (ms)
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
virtual
int
wait
(
Mutex
*
mutex
,
unsigned
long
int
ms
);
/**
* Signal a SINGLE thread to wake if it's waiting.
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
virtual
int
signal
();
/**
* Wake all threads waiting on this condition.
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
virtual
int
broadcast
();
private:
/**
* Private copy constructor, to prevent tampering.
*/
Condition
(
const
Condition
&
/*c*/
)
{};
/**
* Private copy assignment, to prevent tampering.
*/
Condition
&
operator
=
(
const
Condition
&
/*c*/
)
{
return
*
(
this
);};
/**
* Implementation-specific data
*/
void
*
_prvData
;
};
}
#endif // !_OPENTHREADS_CONDITION_
lib/mac64/include/OpenThreads/Config
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenSceneGraph - Copyright (C) 2008 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
/****************************************************************************
* THIS FILE IS AUTOGENERATED BY CMAKE. DO NOT EDIT!
****************************************************************************/
/* Changes to the configuration reflected here can be made with ccmake on
* unix or with cmake-gui on windows. Alternatively you can use cmake's -D
* or -P switches to set some configuration values at cmake configuration time.
*/
#ifndef _OPENTHREADS_CONFIG
#define _OPENTHREADS_CONFIG
#define _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS
/* #undef _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS */
/* #undef _OPENTHREADS_ATOMIC_USE_SUN */
/* #undef _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED */
#define _OPENTHREADS_ATOMIC_USE_BSD_ATOMIC
/* #undef _OPENTHREADS_ATOMIC_USE_MUTEX */
/* #undef OT_LIBRARY_STATIC */
#endif
lib/mac64/include/OpenThreads/Exports
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef _OPENTHREAD_EXPORTS_H_
#define _OPENTHREAD_EXPORTS_H_
#include
<OpenThreads/Config>
#ifndef WIN32
#define OPENTHREAD_EXPORT_DIRECTIVE
#else
#if defined( OT_LIBRARY_STATIC )
#define OPENTHREAD_EXPORT_DIRECTIVE
#elif defined( OPENTHREADS_EXPORTS )
#define OPENTHREAD_EXPORT_DIRECTIVE __declspec(dllexport)
#else
#define OPENTHREAD_EXPORT_DIRECTIVE __declspec(dllimport)
#if 0 // Commented out for now
#ifdef _MSC_VER
#ifdef _DEBUG
#pragma comment(lib ,"OpenThreadsWin32d")
#else
#pragma comment(lib, "OpenThreadsWin32")
#endif
#endif
#endif
#endif
#endif
#endif
lib/mac64/include/OpenThreads/Mutex
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
//
// Mutex - C++ mutex class
// ~~~~~
//
#ifndef _OPENTHREADS_MUTEX_
#define _OPENTHREADS_MUTEX_
#include
<OpenThreads/Exports>
namespace
OpenThreads
{
/**
* @class Mutex
* @brief This class provides an object-oriented thread mutex interface.
*/
class
OPENTHREAD_EXPORT_DIRECTIVE
Mutex
{
friend
class
Condition
;
public:
enum
MutexType
{
MUTEX_NORMAL
,
MUTEX_RECURSIVE
};
/**
* Constructor
*/
Mutex
(
MutexType
type
=
MUTEX_NORMAL
);
/**
* Destructor
*/
virtual
~
Mutex
();
MutexType
getMutexType
()
const
{
return
_mutexType
;
}
/**
* Lock the mutex
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
virtual
int
lock
();
/**
* Unlock the mutex
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
virtual
int
unlock
();
/**
* Test if mutex can be locked.
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
virtual
int
trylock
();
private:
/**
* Private copy constructor, to prevent tampering.
*/
Mutex
(
const
Mutex
&
/*m*/
)
{};
/**
* Private copy assignment, to prevent tampering.
*/
Mutex
&
operator
=
(
const
Mutex
&
/*m*/
)
{
return
*
(
this
);};
/**
* Implementation-specific private data.
*/
void
*
_prvData
;
MutexType
_mutexType
;
};
}
#endif // _OPENTHREADS_MUTEX_
lib/mac64/include/OpenThreads/ReadWriteMutex
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenThreads - Copyright (C) 1998-2007 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef _OPENTHREADS_READWRITEMUTEX_
#define _OPENTHREADS_READWRITEMUTEX_
#include
<OpenThreads/Thread>
#include
<OpenThreads/ReentrantMutex>
namespace
OpenThreads
{
class
ReadWriteMutex
{
public:
ReadWriteMutex
()
:
_readCount
(
0
)
{}
virtual
~
ReadWriteMutex
()
{}
virtual
int
readLock
()
{
OpenThreads
::
ScopedLock
<
OpenThreads
::
Mutex
>
lock
(
_readCountMutex
);
int
result
=
0
;
if
(
_readCount
==
0
)
{
result
=
_readWriteMutex
.
lock
();
}
++
_readCount
;
return
result
;
}
virtual
int
readUnlock
()
{
OpenThreads
::
ScopedLock
<
OpenThreads
::
Mutex
>
lock
(
_readCountMutex
);
int
result
=
0
;
if
(
_readCount
>
0
)
{
--
_readCount
;
if
(
_readCount
==
0
)
{
result
=
_readWriteMutex
.
unlock
();
}
}
return
result
;
}
virtual
int
writeLock
()
{
return
_readWriteMutex
.
lock
();
}
virtual
int
writeUnlock
()
{
return
_readWriteMutex
.
unlock
();
}
protected:
ReadWriteMutex
(
const
ReadWriteMutex
&
)
{}
ReadWriteMutex
&
operator
=
(
const
ReadWriteMutex
&
)
{
return
*
(
this
);
}
#if 0
ReentrantMutex _readWriteMutex;
ReentrantMutex _readCountMutex;
#else
OpenThreads
::
Mutex
_readWriteMutex
;
OpenThreads
::
Mutex
_readCountMutex
;
#endif
unsigned
int
_readCount
;
};
class
ScopedReadLock
{
public:
ScopedReadLock
(
ReadWriteMutex
&
mutex
)
:
_mutex
(
mutex
)
{
_mutex
.
readLock
();
}
~
ScopedReadLock
()
{
_mutex
.
readUnlock
();
}
protected:
ReadWriteMutex
&
_mutex
;
ScopedReadLock
&
operator
=
(
const
ScopedReadLock
&
)
{
return
*
this
;
}
};
class
ScopedWriteLock
{
public:
ScopedWriteLock
(
ReadWriteMutex
&
mutex
)
:
_mutex
(
mutex
)
{
_mutex
.
writeLock
();
}
~
ScopedWriteLock
()
{
_mutex
.
writeUnlock
();
}
protected:
ReadWriteMutex
&
_mutex
;
ScopedWriteLock
&
operator
=
(
const
ScopedWriteLock
&
)
{
return
*
this
;
}
};
}
#endif
lib/mac64/include/OpenThreads/ReentrantMutex
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenThreads - Copyright (C) 1998-2007 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef _OPENTHREADS_REENTRANTMUTEX_
#define _OPENTHREADS_REENTRANTMUTEX_
#include
<OpenThreads/Thread>
#include
<OpenThreads/Mutex>
#include
<OpenThreads/ScopedLock>
namespace
OpenThreads
{
class
ReentrantMutex
:
public
OpenThreads
::
Mutex
{
public:
ReentrantMutex
()
:
Mutex
(
MUTEX_RECURSIVE
)
{}
};
}
#endif
lib/mac64/include/OpenThreads/ScopedLock
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
//
// ScopedLock and ReverseScopedLock templates
// ~~~~~~~
//
#ifndef _ScopedLock_
#define _ScopedLock_
namespace
OpenThreads
{
template
<
class
M
>
class
ScopedLock
{
private:
M
&
m_lock
;
ScopedLock
(
const
ScopedLock
&
);
// prevent copy
ScopedLock
&
operator
=
(
const
ScopedLock
&
);
// prevent assign
public:
explicit
ScopedLock
(
M
&
m
)
:
m_lock
(
m
)
{
m_lock
.
lock
();}
~
ScopedLock
(){
m_lock
.
unlock
();}
};
template
<
class
M
>
class
ReverseScopedLock
{
private:
M
&
m_lock
;
ReverseScopedLock
(
const
ReverseScopedLock
&
);
// prevent copy
ReverseScopedLock
&
operator
=
(
const
ReverseScopedLock
&
);
// prevent assign
public:
explicit
ReverseScopedLock
(
M
&
m
)
:
m_lock
(
m
)
{
m_lock
.
unlock
();}
~
ReverseScopedLock
(){
m_lock
.
lock
();}
};
template
<
class
M
>
class
ScopedPointerLock
{
private:
M
*
m_lock
;
ScopedPointerLock
(
const
ScopedPointerLock
&
);
// prevent copy
ScopedPointerLock
&
operator
=
(
const
ScopedPointerLock
&
);
// prevent assign
public:
explicit
ScopedPointerLock
(
M
*
m
)
:
m_lock
(
m
)
{
if
(
m_lock
)
m_lock
->
lock
();}
~
ScopedPointerLock
(){
if
(
m_lock
)
m_lock
->
unlock
();}
};
template
<
class
M
>
class
ReverseScopedPointerLock
{
private:
M
*
m_lock
;
ReverseScopedPointerLock
(
const
ReverseScopedPointerLock
&
);
// prevent copy
ReverseScopedPointerLock
&
operator
=
(
const
ReverseScopedPointerLock
&
);
// prevent assign
public:
explicit
ReverseScopedPointerLock
(
M
*
m
)
:
m_lock
(
m
)
{
if
(
m_lock
)
m_lock
->
unlock
();}
~
ReverseScopedPointerLock
(){
if
(
m_lock
)
m_lock
->
lock
();}
};
}
#endif
lib/mac64/include/OpenThreads/Thread
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
//
// Thread - C++ Thread class
// ~~~~~~~~
//
#ifndef _OPENTHREADS_THREAD_
#define _OPENTHREADS_THREAD_
#include
<sys/types.h>
#include
<OpenThreads/Mutex>
namespace
OpenThreads
{
/**
* Get the number of processors.
*
* Note, systems where no support exists for querrying the number of processors, 1 is returned.
*
*/
extern
OPENTHREAD_EXPORT_DIRECTIVE
int
GetNumberOfProcessors
();
/**
* Set the processor affinity of current thread.
*
* Note, systems where no support exists no affinity will be set, and -1 will be returned.
*
*/
extern
OPENTHREAD_EXPORT_DIRECTIVE
int
SetProcessorAffinityOfCurrentThread
(
unsigned
int
cpunum
);
/**
* @class Thread
* @brief This class provides an object-oriented thread interface.
*/
class
OPENTHREAD_EXPORT_DIRECTIVE
Thread
{
public:
/**
* Set the concurrency level for a running application. This method
* only has effect if the pthreads thread model is being used, and
* then only when that model is many-to-one (eg. irix).
* in other cases it is ignored. The concurrency level is only a
* *hint* as to the number of execution vehicles to use, the actual
* implementation may do anything it wants. Setting the value
* to 0 returns things to their default state.
*
* @return previous concurrency level, -1 indicates no-op.
*/
static
int
SetConcurrency
(
int
concurrencyLevel
);
/**
* Get the concurrency level for a running application. In this
* case, a return code of 0 means that the application is in default
* mode. A return code of -1 means that the application is incapable
* of setting an arbitrary concurrency, because it is a one-to-one
* execution model (sprocs, linuxThreads)
*/
static
int
GetConcurrency
();
/**
* Enumerated Type for thread priority
*/
enum
ThreadPriority
{
THREAD_PRIORITY_MAX
,
/**< The maximum possible priority */
THREAD_PRIORITY_HIGH
,
/**< A high (but not max) setting */
THREAD_PRIORITY_NOMINAL
,
/**< An average priority */
THREAD_PRIORITY_LOW
,
/**< A low (but not min) setting */
THREAD_PRIORITY_MIN
,
/**< The miniumum possible priority */
THREAD_PRIORITY_DEFAULT
/**< Priority scheduling default */
};
/**
* Enumerated Type for thread scheduling policy
*/
enum
ThreadPolicy
{
THREAD_SCHEDULE_FIFO
,
/**< First in, First out scheduling */
THREAD_SCHEDULE_ROUND_ROBIN
,
/**< Round-robin scheduling (LINUX_DEFAULT) */
THREAD_SCHEDULE_TIME_SHARE
,
/**< Time-share scheduling (IRIX DEFAULT) */
THREAD_SCHEDULE_DEFAULT
/**< Default scheduling */
};
/**
* Constructor
*/
Thread
();
/**
* Destructor
*/
virtual
~
Thread
();
/**
* Return a pointer to the current running thread
*/
static
Thread
*
CurrentThread
();
/**
* Initialize Threading in a program. This method must be called before
* you can do any threading in a program.
*/
static
void
Init
();
/**
* Yield the processor.
*
* @note This method operates on the calling process. And is
* equivalent to calling sched_yield().
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
static
int
YieldCurrentThread
();
/**
* This method will return the ThreadPriority of the master process.
* (ie, the one calling the thread->start() methods for the first time)
* The method will almost certainly return
* Thread::THREAD_PRIORITY_DEFAULT if
* Init() has not been called.
*
* @return the Thread::ThreadPriority of the master thread.
*/
static
ThreadPriority
GetMasterPriority
()
{
return
s_masterThreadPriority
;};
/**
* Get a unique thread id. This id is monotonically increasing.
*
* @return a unique thread identifier
*/
int
getThreadId
();
/**
* Get the thread's process id. This is the pthread_t or pid_t value
* depending on the threading model being used.
*
* @return thread process id.
*/
size_t
getProcessId
();
/**
* Start the thread. This method will configure the thread, set
* it's priority, and spawn it.
*
* @note if the stack size specified setStackSize is smaller than the
* smallest allowable stack size, the threads stack size will be set to
* the minimum allowed, and may be retrieved via the getStackSize()
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
int
start
();
int
startThread
();
/**
* Test the cancel state of the thread. If the thread has been canceled
* this method will cause the thread to exit now. This method operates
* on the calling thread.
*
* Returns 0 if normal, -1 if called from a thread other that this.
*/
int
testCancel
();
/**
* Cancel the thread. Equivalent to SIGKILL.
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
virtual
int
cancel
();
/**
* Set the thread's schedule priority. This is a complex method.
* Beware of thread priorities when using a many-to-many kernel
* entity implemenation (such as IRIX pthreads). If one is not carefull
* to manage the thread priorities, a priority inversion deadlock can
* easily occur (Although the OpenThreads::Mutex & OpenThreads::Barrier
* constructs have been designed with this senario in mind). Unless
* you have explicit need to set the schedule pirorites for a given
* task, it is best to leave them alone.
*
* @note some implementations (notably LinuxThreads and IRIX Sprocs)
* only alow you to decrease thread priorities dynamically. Thus,
* a lower priority thread will not allow it's priority to be raised
* on the fly.
*
* @note seting the environment variable OUTPUT_THREADLIB_SCHEDULING_INFO
* will output scheduling information for each thread to stdout.
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
int
setSchedulePriority
(
ThreadPriority
priority
);
/**
* Get the thread's schedule priority (if able)
*
* @note seting the environment variable OUTPUT_THREADLIB_SCHEDULING_INFO
* will output scheduling information for each thread to stdout.
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
int
getSchedulePriority
();
/**
* Set the thread's scheduling policy (if able)
*
* @note On some implementations (notably IRIX Sprocs & LinuxThreads)
* The policy may prohibit the use of SCHEDULE_ROUND_ROBIN and
* SCHEDULE_FIFO policies - due to their real-time nature, and
* the danger of deadlocking the machine when used as super-user.
* In such cases, the command is a no-op.
*
* @note seting the environment variable OUTPUT_THREADLIB_SCHEDULING_INFO
* will output scheduling information for each thread to stdout.
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
int
setSchedulePolicy
(
ThreadPolicy
policy
);
/**
* Get the thread's policy (if able)
*
* @note seting the environment variable OUTPUT_THREADLIB_SCHEDULING_INFO
* will output scheduling information for each thread to stdout.
*
* @return policy if normal, -1 if errno set, errno code otherwise.
*/
int
getSchedulePolicy
();
/**
* Set the thread's desired stack size (in bytes).
* This method is an attribute of the thread and must be called
* *before* the start() method is invoked.
*
* @note a return code of 13 (EACESS) means that the thread stack
* size can no longer be changed.
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
int
setStackSize
(
size_t
size
);
/**
* Get the thread's desired stack size.
*
* @return the thread's stack size. 0 indicates that the stack size
* has either not yet been initialized, or not yet been specified by
* the application.
*/
size_t
getStackSize
();
/**
* Print the thread's scheduling information to stdout.
*/
void
printSchedulingInfo
();
/**
* Detach the thread from the calling process.
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
int
detach
();
/**
* Join the calling process with the thread
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
int
join
();
/**
* Disable thread cancelation altogether. Thread::cancel() has no effect.
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
int
setCancelModeDisable
();
/**
* Mark the thread to cancel aysncronously on Thread::cancel().
* (May not be available with process-level implementations).
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
int
setCancelModeAsynchronous
();
/**
* Mark the thread to cancel at the earliest convenience on
* Thread::cancel() (This is the default)
*
* @return 0 if normal, -1 if errno set, errno code otherwise.
*/
int
setCancelModeDeferred
();
/**
* Query the thread's running status
*
* @return true if running, false if not.
*/
bool
isRunning
();
/**
* Thread's run method. Must be implemented by derived classes.
* This is where the action happens.
*/
virtual
void
run
()
=
0
;
/**
* Thread's cancel cleanup routine, called upon cancel(), after the
* cancelation has taken place, but before the thread exits completely.
* This method should be used to repair parts of the thread's data
* that may have been damaged by a pre-mature cancel. No-op by default.
*/
virtual
void
cancelCleanup
()
{};
void
*
getImplementation
(){
return
_prvData
;
};
/** Thread's processor affinity method. This binds a thread to a
* processor whenever possible. This call must be made before
* start() or startThread() and has no effect after the thread
* has been running. In the pthreads implementation, this is only
* implemented on sgi, through a pthread extension. On other pthread
* platforms this is ignored. Returns 0 on success, implementation's
* error on failure, or -1 if ignored.
*/
int
setProcessorAffinity
(
unsigned
int
cpunum
);
/** microSleep method, equivilant to the posix usleep(microsec).
* This is not strictly thread API but is used
* so often with threads. It's basically UNIX usleep. Parameter is
* number of microseconds we current thread to sleep. Returns 0 on
* succes, non-zero on failure (UNIX errno or GetLastError() will give
* detailed description.
*/
static
int
microSleep
(
unsigned
int
microsec
);
private:
/**
* The Private Actions class is allowed to operate on private data.
*/
friend
class
ThreadPrivateActions
;
/**
* Private copy constructor, to prevent tampering.
*/
Thread
(
const
Thread
&
/*t*/
)
{};
/**
* Private copy assignment, to prevent tampering.
*/
Thread
&
operator
=
(
const
Thread
&
/*t*/
)
{
return
*
(
this
);};
/**
* Implementation-specific data
*/
void
*
_prvData
;
/**
* Master thread's priority, set by Thread::Init.
*/
static
ThreadPriority
s_masterThreadPriority
;
/**
* Is initialized flag
*/
static
bool
s_isInitialized
;
};
}
#endif // !_OPENTHREADS_THREAD_
lib/mac64/include/OpenThreads/Version
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OPENTHREADS_VERSION
#define OPENTHREADS_VERSION 1
#include
<OpenThreads/Exports>
extern
"C"
{
#define OPENTHREADS_MAJOR_VERSION 2
#define OPENTHREADS_MINOR_VERSION 6
#define OPENTHREADS_PATCH_VERSION 0
#define OPENTHREADS_SOVERSION 12
/** OpenThreadsGetVersion() returns the library version number.
* Numbering convention : OpenThreads-1.0 will return 1.0 from OpenThreadsGetVersion. */
extern
OPENTHREAD_EXPORT_DIRECTIVE
const
char
*
OpenThreadsGetVersion
();
/** The OpenThreadsGetSOVersion() method returns the OpenSceneGraph soversion number. */
extern
OPENTHREAD_EXPORT_DIRECTIVE
const
char
*
OpenThreadsGetSOVersion
();
/** The OpenThreadsGetLibraryName() method returns the library name in human-friendly form. */
extern
OPENTHREAD_EXPORT_DIRECTIVE
const
char
*
OpenThreadsGetLibraryName
();
}
#endif
lib/mac64/include/osg/AlphaFunc
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_ALPHAFUNC
#define OSG_ALPHAFUNC 1
#include
<osg/StateAttribute>
#ifndef GL_ALPHA_TEST
#define GL_ALPHA_TEST 0x0BC0
#endif
namespace
osg
{
/** Encapsulates OpenGL glAlphaFunc.
*/
class
OSG_EXPORT
AlphaFunc
:
public
StateAttribute
{
public
:
enum
ComparisonFunction
{
NEVER
=
GL_NEVER
,
LESS
=
GL_LESS
,
EQUAL
=
GL_EQUAL
,
LEQUAL
=
GL_LEQUAL
,
GREATER
=
GL_GREATER
,
NOTEQUAL
=
GL_NOTEQUAL
,
GEQUAL
=
GL_GEQUAL
,
ALWAYS
=
GL_ALWAYS
};
AlphaFunc
();
AlphaFunc
(
ComparisonFunction
func
,
float
ref
)
:
_comparisonFunc
(
func
),
_referenceValue
(
ref
)
{}
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
AlphaFunc
(
const
AlphaFunc
&
af
,
const
CopyOp
&
copyop
=
CopyOp
::
SHALLOW_COPY
)
:
StateAttribute
(
af
,
copyop
),
_comparisonFunc
(
af
.
_comparisonFunc
),
_referenceValue
(
af
.
_referenceValue
)
{}
META_StateAttribute
(
osg
,
AlphaFunc
,
ALPHAFUNC
);
/** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
virtual
int
compare
(
const
StateAttribute
&
sa
)
const
{
// Check for equal types, then create the rhs variable
// used by the COMPARE_StateAttribute_Parameter macros below.
COMPARE_StateAttribute_Types
(
AlphaFunc
,
sa
)
// Compare each parameter in turn against the rhs.
COMPARE_StateAttribute_Parameter
(
_comparisonFunc
)
COMPARE_StateAttribute_Parameter
(
_referenceValue
)
return
0
;
// Passed all the above comparison macros, so must be equal.
}
virtual
bool
getModeUsage
(
StateAttribute
::
ModeUsage
&
usage
)
const
{
usage
.
usesMode
(
GL_ALPHA_TEST
);
return
true
;
}
inline
void
setFunction
(
ComparisonFunction
func
,
float
ref
)
{
_comparisonFunc
=
func
;
_referenceValue
=
ref
;
}
inline
void
setFunction
(
ComparisonFunction
func
)
{
_comparisonFunc
=
func
;
}
inline
ComparisonFunction
getFunction
()
const
{
return
_comparisonFunc
;
}
inline
void
setReferenceValue
(
float
value
)
{
_referenceValue
=
value
;
}
inline
float
getReferenceValue
()
const
{
return
_referenceValue
;
}
virtual
void
apply
(
State
&
state
)
const
;
protected:
virtual
~
AlphaFunc
();
ComparisonFunction
_comparisonFunc
;
float
_referenceValue
;
};
}
#endif
lib/mac64/include/osg/AnimationPath
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_ANIMATIONPATH
#define OSG_ANIMATIONPATH 1
#include
<map>
#include
<istream>
#include
<float.h>
#include
<osg/Matrixf>
#include
<osg/Matrixd>
#include
<osg/Quat>
#include
<osg/NodeCallback>
namespace
osg
{
/** AnimationPath encapsulates a time varying transformation pathway. Can be
* used for updating camera position and model object position.
* AnimationPathCallback can be attached directly to Transform nodes to
* move subgraphs around the scene.
*/
class
OSG_EXPORT
AnimationPath
:
public
virtual
osg
::
Object
{
public:
AnimationPath
()
:
_loopMode
(
LOOP
)
{}
AnimationPath
(
const
AnimationPath
&
ap
,
const
CopyOp
&
copyop
=
CopyOp
::
SHALLOW_COPY
)
:
Object
(
ap
,
copyop
),
_timeControlPointMap
(
ap
.
_timeControlPointMap
),
_loopMode
(
ap
.
_loopMode
)
{}
META_Object
(
osg
,
AnimationPath
);
class
ControlPoint
{
public:
ControlPoint
()
:
_scale
(
1.0
,
1.0
,
1.0
)
{}
ControlPoint
(
const
osg
::
Vec3d
&
position
)
:
_position
(
position
),
_rotation
(),
_scale
(
1.0
,
1.0
,
1.0
)
{}
ControlPoint
(
const
osg
::
Vec3d
&
position
,
const
osg
::
Quat
&
rotation
)
:
_position
(
position
),
_rotation
(
rotation
),
_scale
(
1.0
,
1.0
,
1.0
)
{}
ControlPoint
(
const
osg
::
Vec3d
&
position
,
const
osg
::
Quat
&
rotation
,
const
osg
::
Vec3d
&
scale
)
:
_position
(
position
),
_rotation
(
rotation
),
_scale
(
scale
)
{}
void
setPosition
(
const
osg
::
Vec3d
&
position
)
{
_position
=
position
;
}
const
osg
::
Vec3d
&
getPosition
()
const
{
return
_position
;
}
void
setRotation
(
const
osg
::
Quat
&
rotation
)
{
_rotation
=
rotation
;
}
const
osg
::
Quat
&
getRotation
()
const
{
return
_rotation
;
}
void
setScale
(
const
osg
::
Vec3d
&
scale
)
{
_scale
=
scale
;
}
const
osg
::
Vec3d
&
getScale
()
const
{
return
_scale
;
}
inline
void
interpolate
(
float
ratio
,
const
ControlPoint
&
first
,
const
ControlPoint
&
second
)
{
float
one_minus_ratio
=
1.0
f
-
ratio
;
_position
=
first
.
_position
*
one_minus_ratio
+
second
.
_position
*
ratio
;
_rotation
.
slerp
(
ratio
,
first
.
_rotation
,
second
.
_rotation
);
_scale
=
first
.
_scale
*
one_minus_ratio
+
second
.
_scale
*
ratio
;
}
inline
void
interpolate
(
double
ratio
,
const
ControlPoint
&
first
,
const
ControlPoint
&
second
)
{
double
one_minus_ratio
=
1.0
f
-
ratio
;
_position
=
first
.
_position
*
one_minus_ratio
+
second
.
_position
*
ratio
;
_rotation
.
slerp
(
ratio
,
first
.
_rotation
,
second
.
_rotation
);
_scale
=
first
.
_scale
*
one_minus_ratio
+
second
.
_scale
*
ratio
;
}
inline
void
getMatrix
(
Matrixf
&
matrix
)
const
{
matrix
.
makeRotate
(
_rotation
);
matrix
.
preMultScale
(
_scale
);
matrix
.
postMultTranslate
(
_position
);
}
inline
void
getMatrix
(
Matrixd
&
matrix
)
const
{
matrix
.
makeRotate
(
_rotation
);
matrix
.
preMultScale
(
_scale
);
matrix
.
postMultTranslate
(
_position
);
}
inline
void
getInverse
(
Matrixf
&
matrix
)
const
{
matrix
.
makeRotate
(
_rotation
.
inverse
());
matrix
.
postMultScale
(
osg
::
Vec3d
(
1.0
/
_scale
.
x
(),
1.0
/
_scale
.
y
(),
1.0
/
_scale
.
z
()));
matrix
.
preMultTranslate
(
-
_position
);
}
inline
void
getInverse
(
Matrixd
&
matrix
)
const
{
matrix
.
makeRotate
(
_rotation
.
inverse
());
matrix
.
postMultScale
(
osg
::
Vec3d
(
1.0
/
_scale
.
x
(),
1.0
/
_scale
.
y
(),
1.0
/
_scale
.
z
()));
matrix
.
preMultTranslate
(
-
_position
);
}
protected:
osg
::
Vec3d
_position
;
osg
::
Quat
_rotation
;
osg
::
Vec3d
_scale
;
};
/** Given a specific time, return the transformation matrix for a point. */
bool
getMatrix
(
double
time
,
Matrixf
&
matrix
)
const
{
ControlPoint
cp
;
if
(
!
getInterpolatedControlPoint
(
time
,
cp
))
return
false
;
cp
.
getMatrix
(
matrix
);
return
true
;
}
/** Given a specific time, return the transformation matrix for a point. */
bool
getMatrix
(
double
time
,
Matrixd
&
matrix
)
const
{
ControlPoint
cp
;
if
(
!
getInterpolatedControlPoint
(
time
,
cp
))
return
false
;
cp
.
getMatrix
(
matrix
);
return
true
;
}
/** Given a specific time, return the inverse transformation matrix for a point. */
bool
getInverse
(
double
time
,
Matrixf
&
matrix
)
const
{
ControlPoint
cp
;
if
(
!
getInterpolatedControlPoint
(
time
,
cp
))
return
false
;
cp
.
getInverse
(
matrix
);
return
true
;
}
bool
getInverse
(
double
time
,
Matrixd
&
matrix
)
const
{
ControlPoint
cp
;
if
(
!
getInterpolatedControlPoint
(
time
,
cp
))
return
false
;
cp
.
getInverse
(
matrix
);
return
true
;
}
/** Given a specific time, return the local ControlPoint frame for a point. */
virtual
bool
getInterpolatedControlPoint
(
double
time
,
ControlPoint
&
controlPoint
)
const
;
/** Insert a control point into the AnimationPath.*/
void
insert
(
double
time
,
const
ControlPoint
&
controlPoint
);
double
getFirstTime
()
const
{
if
(
!
_timeControlPointMap
.
empty
())
return
_timeControlPointMap
.
begin
()
->
first
;
else
return
0.0
;}
double
getLastTime
()
const
{
if
(
!
_timeControlPointMap
.
empty
())
return
_timeControlPointMap
.
rbegin
()
->
first
;
else
return
0.0
;}
double
getPeriod
()
const
{
return
getLastTime
()
-
getFirstTime
();}
enum
LoopMode
{
SWING
,
LOOP
,
NO_LOOPING
};
void
setLoopMode
(
LoopMode
lm
)
{
_loopMode
=
lm
;
}
LoopMode
getLoopMode
()
const
{
return
_loopMode
;
}
typedef
std
::
map
<
double
,
ControlPoint
>
TimeControlPointMap
;
void
setTimeControlPointMap
(
TimeControlPointMap
&
tcpm
)
{
_timeControlPointMap
=
tcpm
;
}
TimeControlPointMap
&
getTimeControlPointMap
()
{
return
_timeControlPointMap
;
}
const
TimeControlPointMap
&
getTimeControlPointMap
()
const
{
return
_timeControlPointMap
;
}
bool
empty
()
const
{
return
_timeControlPointMap
.
empty
();
}
void
clear
()
{
_timeControlPointMap
.
clear
();
}
/** Read the animation path from a flat ASCII file stream. */
void
read
(
std
::
istream
&
in
);
/** Write the animation path to a flat ASCII file stream. */
void
write
(
std
::
ostream
&
out
)
const
;
/** Write the control point to a flat ASCII file stream. */
void
write
(
TimeControlPointMap
::
const_iterator
itr
,
std
::
ostream
&
out
)
const
;
protected:
virtual
~
AnimationPath
()
{}
TimeControlPointMap
_timeControlPointMap
;
LoopMode
_loopMode
;
};
class
OSG_EXPORT
AnimationPathCallback
:
public
NodeCallback
{
public:
AnimationPathCallback
()
:
_pivotPoint
(
0.0
,
0.0
,
0.0
),
_useInverseMatrix
(
false
),
_timeOffset
(
0.0
),
_timeMultiplier
(
1.0
),
_firstTime
(
DBL_MAX
),
_latestTime
(
0.0
),
_pause
(
false
),
_pauseTime
(
0.0
)
{}
AnimationPathCallback
(
const
AnimationPathCallback
&
apc
,
const
CopyOp
&
copyop
)
:
NodeCallback
(
apc
,
copyop
),
_animationPath
(
apc
.
_animationPath
),
_pivotPoint
(
apc
.
_pivotPoint
),
_useInverseMatrix
(
apc
.
_useInverseMatrix
),
_timeOffset
(
apc
.
_timeOffset
),
_timeMultiplier
(
apc
.
_timeMultiplier
),
_firstTime
(
apc
.
_firstTime
),
_latestTime
(
apc
.
_latestTime
),
_pause
(
apc
.
_pause
),
_pauseTime
(
apc
.
_pauseTime
)
{}
META_Object
(
osg
,
AnimationPathCallback
);
/** Construct an AnimationPathCallback with a specified animation path.*/
AnimationPathCallback
(
AnimationPath
*
ap
,
double
timeOffset
=
0.0
,
double
timeMultiplier
=
1.0
)
:
_animationPath
(
ap
),
_pivotPoint
(
0.0
,
0.0
,
0.0
),
_useInverseMatrix
(
false
),
_timeOffset
(
timeOffset
),
_timeMultiplier
(
timeMultiplier
),
_firstTime
(
DBL_MAX
),
_latestTime
(
0.0
),
_pause
(
false
),
_pauseTime
(
0.0
)
{}
/** Construct an AnimationPathCallback and automatically create an animation path to produce a rotation about a point.*/
AnimationPathCallback
(
const
osg
::
Vec3d
&
pivot
,
const
osg
::
Vec3d
&
axis
,
float
angularVelocity
);
void
setAnimationPath
(
AnimationPath
*
path
)
{
_animationPath
=
path
;
}
AnimationPath
*
getAnimationPath
()
{
return
_animationPath
.
get
();
}
const
AnimationPath
*
getAnimationPath
()
const
{
return
_animationPath
.
get
();
}
inline
void
setPivotPoint
(
const
Vec3d
&
pivot
)
{
_pivotPoint
=
pivot
;
}
inline
const
Vec3d
&
getPivotPoint
()
const
{
return
_pivotPoint
;
}
void
setUseInverseMatrix
(
bool
useInverseMatrix
)
{
_useInverseMatrix
=
useInverseMatrix
;
}
bool
getUseInverseMatrix
()
const
{
return
_useInverseMatrix
;
}
void
setTimeOffset
(
double
offset
)
{
_timeOffset
=
offset
;
}
double
getTimeOffset
()
const
{
return
_timeOffset
;
}
void
setTimeMultiplier
(
double
multiplier
)
{
_timeMultiplier
=
multiplier
;
}
double
getTimeMultiplier
()
const
{
return
_timeMultiplier
;
}
virtual
void
reset
();
void
setPause
(
bool
pause
);
bool
getPause
()
const
{
return
_pause
;
}
/** Get the animation time that is used to specify the position along
* the AnimationPath. Animation time is computed from the formula:
* ((_latestTime-_firstTime)-_timeOffset)*_timeMultiplier.*/
virtual
double
getAnimationTime
()
const
;
/** Implements the callback. */
virtual
void
operator
()(
Node
*
node
,
NodeVisitor
*
nv
);
void
update
(
osg
::
Node
&
node
);
public:
ref_ptr
<
AnimationPath
>
_animationPath
;
osg
::
Vec3d
_pivotPoint
;
bool
_useInverseMatrix
;
double
_timeOffset
;
double
_timeMultiplier
;
double
_firstTime
;
double
_latestTime
;
bool
_pause
;
double
_pauseTime
;
protected:
~
AnimationPathCallback
(){}
};
}
#endif
lib/mac64/include/osg/ApplicationUsage
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_APPLICATIONUSAGE
#define OSG_APPLICATIONUSAGE 1
#include
<osg/Referenced>
#include
<map>
#include
<string>
#include
<ostream>
namespace
osg
{
class
OSG_EXPORT
ApplicationUsage
:
public
osg
::
Referenced
{
public:
static
ApplicationUsage
*
instance
();
ApplicationUsage
()
{}
ApplicationUsage
(
const
std
::
string
&
commandLineUsage
);
typedef
std
::
map
<
std
::
string
,
std
::
string
>
UsageMap
;
/** The ApplicationName is often displayed when logging errors, and frequently incorporated into the Description (below). */
void
setApplicationName
(
const
std
::
string
&
name
)
{
_applicationName
=
name
;
}
const
std
::
string
&
getApplicationName
()
const
{
return
_applicationName
;
}
/** If non-empty, the Description is typically shown by the Help Handler
* as text on the Help display (which also lists keyboard abbreviations. */
void
setDescription
(
const
std
::
string
&
desc
)
{
_description
=
desc
;
}
const
std
::
string
&
getDescription
()
const
{
return
_description
;
}
enum
Type
{
NO_HELP
=
0x0
,
COMMAND_LINE_OPTION
=
0x1
,
ENVIRONMENTAL_VARIABLE
=
0x2
,
KEYBOARD_MOUSE_BINDING
=
0x4
,
HELP_ALL
=
KEYBOARD_MOUSE_BINDING
|
ENVIRONMENTAL_VARIABLE
|
COMMAND_LINE_OPTION
};
void
addUsageExplanation
(
Type
type
,
const
std
::
string
&
option
,
const
std
::
string
&
explanation
);
void
setCommandLineUsage
(
const
std
::
string
&
explanation
)
{
_commandLineUsage
=
explanation
;
}
const
std
::
string
&
getCommandLineUsage
()
const
{
return
_commandLineUsage
;
}
void
addCommandLineOption
(
const
std
::
string
&
option
,
const
std
::
string
&
explanation
,
const
std
::
string
&
defaultValue
=
""
);
void
setCommandLineOptions
(
const
UsageMap
&
usageMap
)
{
_commandLineOptions
=
usageMap
;
}
const
UsageMap
&
getCommandLineOptions
()
const
{
return
_commandLineOptions
;
}
void
setCommandLineOptionsDefaults
(
const
UsageMap
&
usageMap
)
{
_commandLineOptionsDefaults
=
usageMap
;
}
const
UsageMap
&
getCommandLineOptionsDefaults
()
const
{
return
_commandLineOptionsDefaults
;
}
void
addEnvironmentalVariable
(
const
std
::
string
&
option
,
const
std
::
string
&
explanation
,
const
std
::
string
&
defaultValue
=
""
);
void
setEnvironmentalVariables
(
const
UsageMap
&
usageMap
)
{
_environmentalVariables
=
usageMap
;
}
const
UsageMap
&
getEnvironmentalVariables
()
const
{
return
_environmentalVariables
;
}
void
setEnvironmentalVariablesDefaults
(
const
UsageMap
&
usageMap
)
{
_environmentalVariablesDefaults
=
usageMap
;
}
const
UsageMap
&
getEnvironmentalVariablesDefaults
()
const
{
return
_environmentalVariablesDefaults
;
}
void
addKeyboardMouseBinding
(
const
std
::
string
&
option
,
const
std
::
string
&
explanation
);
void
setKeyboardMouseBindings
(
const
UsageMap
&
usageMap
)
{
_keyboardMouse
=
usageMap
;
}
const
UsageMap
&
getKeyboardMouseBindings
()
const
{
return
_keyboardMouse
;
}
void
getFormattedString
(
std
::
string
&
str
,
const
UsageMap
&
um
,
unsigned
int
widthOfOutput
=
80
,
bool
showDefaults
=
false
,
const
UsageMap
&
ud
=
UsageMap
());
void
write
(
std
::
ostream
&
output
,
const
UsageMap
&
um
,
unsigned
int
widthOfOutput
=
80
,
bool
showDefaults
=
false
,
const
UsageMap
&
ud
=
UsageMap
());
void
write
(
std
::
ostream
&
output
,
unsigned
int
type
=
COMMAND_LINE_OPTION
,
unsigned
int
widthOfOutput
=
80
,
bool
showDefaults
=
false
);
void
writeEnvironmentSettings
(
std
::
ostream
&
output
);
protected:
virtual
~
ApplicationUsage
()
{}
std
::
string
_applicationName
;
std
::
string
_description
;
std
::
string
_commandLineUsage
;
UsageMap
_commandLineOptions
;
UsageMap
_environmentalVariables
;
UsageMap
_keyboardMouse
;
UsageMap
_environmentalVariablesDefaults
;
UsageMap
_commandLineOptionsDefaults
;
};
class
ApplicationUsageProxy
{
public:
/** register an explanation of commandline/environmentvariable/keyboard mouse usage.*/
ApplicationUsageProxy
(
ApplicationUsage
::
Type
type
,
const
std
::
string
&
option
,
const
std
::
string
&
explanation
)
{
ApplicationUsage
::
instance
()
->
addUsageExplanation
(
type
,
option
,
explanation
);
}
};
}
#endif
lib/mac64/include/osg/ArgumentParser
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_ARGUMENTPARSER
#define OSG_ARGUMENTPARSER 1
#include
<osg/Export>
#include
<osg/ref_ptr>
#include
<osg/ApplicationUsage>
#include
<map>
#include
<string>
#include
<ostream>
namespace
osg
{
class
OSG_EXPORT
ArgumentParser
{
public:
class
OSG_EXPORT
Parameter
{
public:
enum
ParameterType
{
BOOL_PARAMETER
,
FLOAT_PARAMETER
,
DOUBLE_PARAMETER
,
INT_PARAMETER
,
UNSIGNED_INT_PARAMETER
,
STRING_PARAMETER
};
union
ValueUnion
{
bool
*
_bool
;
float
*
_float
;
double
*
_double
;
int
*
_int
;
unsigned
int
*
_uint
;
std
::
string
*
_string
;
};
Parameter
(
bool
&
value
)
{
_type
=
BOOL_PARAMETER
;
_value
.
_bool
=
&
value
;
}
Parameter
(
float
&
value
)
{
_type
=
FLOAT_PARAMETER
;
_value
.
_float
=
&
value
;
}
Parameter
(
double
&
value
)
{
_type
=
DOUBLE_PARAMETER
;
_value
.
_double
=
&
value
;
}
Parameter
(
int
&
value
)
{
_type
=
INT_PARAMETER
;
_value
.
_int
=
&
value
;
}
Parameter
(
unsigned
int
&
value
)
{
_type
=
UNSIGNED_INT_PARAMETER
;
_value
.
_uint
=
&
value
;
}
Parameter
(
std
::
string
&
value
)
{
_type
=
STRING_PARAMETER
;
_value
.
_string
=
&
value
;
}
Parameter
(
const
Parameter
&
param
)
{
_type
=
param
.
_type
;
_value
=
param
.
_value
;
}
Parameter
&
operator
=
(
const
Parameter
&
param
)
{
_type
=
param
.
_type
;
_value
=
param
.
_value
;
return
*
this
;
}
bool
valid
(
const
char
*
str
)
const
;
bool
assign
(
const
char
*
str
);
protected:
ParameterType
_type
;
ValueUnion
_value
;
};
/** Return true if the specified string is an option in the form
* -option or --option. */
static
bool
isOption
(
const
char
*
str
);
/** Return true if string is non-NULL and not an option in the form
* -option or --option. */
static
bool
isString
(
const
char
*
str
);
/** Return true if specified parameter is a number. */
static
bool
isNumber
(
const
char
*
str
);
/** Return true if specified parameter is a bool. */
static
bool
isBool
(
const
char
*
str
);
public:
ArgumentParser
(
int
*
argc
,
char
**
argv
);
void
setApplicationUsage
(
ApplicationUsage
*
usage
)
{
_usage
=
usage
;
}
ApplicationUsage
*
getApplicationUsage
()
{
return
_usage
.
get
();
}
const
ApplicationUsage
*
getApplicationUsage
()
const
{
return
_usage
.
get
();
}
/** Return the argument count. */
int
&
argc
()
{
return
*
_argc
;
}
/** Return the argument array. */
char
**
argv
()
{
return
_argv
;
}
/** Return the char* argument at the specified position. */
char
*
operator
[]
(
int
pos
)
{
return
_argv
[
pos
];
}
/** Return the const char* argument at the specified position. */
const
char
*
operator
[]
(
int
pos
)
const
{
return
_argv
[
pos
];
}
/** Return the application name, as specified by argv[0] */
std
::
string
getApplicationName
()
const
;
/** Return the position of an occurrence of a string in the argument list.
* Return -1 if no string is found. */
int
find
(
const
std
::
string
&
str
)
const
;
/** Return true if the specified parameter is an option in the form of
* -option or --option. */
bool
isOption
(
int
pos
)
const
;
/** Return true if the specified parameter is a string not in
* the form of an option. */
bool
isString
(
int
pos
)
const
;
/** Return true if the specified parameter is a number. */
bool
isNumber
(
int
pos
)
const
;
bool
containsOptions
()
const
;
/** Remove one or more arguments from the argv argument list,
* and decrement the argc respectively. */
void
remove
(
int
pos
,
int
num
=
1
);
/** Return true if the specified argument matches the given string. */
bool
match
(
int
pos
,
const
std
::
string
&
str
)
const
;
/** Search for an occurrence of a string in the argument list. If found,
* remove that occurrence and return true. Otherwise, return false. */
bool
read
(
const
std
::
string
&
str
);
bool
read
(
const
std
::
string
&
str
,
Parameter
value1
);
bool
read
(
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
);
bool
read
(
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
,
Parameter
value3
);
bool
read
(
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
,
Parameter
value3
,
Parameter
value4
);
bool
read
(
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
,
Parameter
value3
,
Parameter
value4
,
Parameter
value5
);
bool
read
(
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
,
Parameter
value3
,
Parameter
value4
,
Parameter
value5
,
Parameter
value6
);
bool
read
(
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
,
Parameter
value3
,
Parameter
value4
,
Parameter
value5
,
Parameter
value6
,
Parameter
value7
);
bool
read
(
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
,
Parameter
value3
,
Parameter
value4
,
Parameter
value5
,
Parameter
value6
,
Parameter
value7
,
Parameter
value8
);
/** If the argument value at the specified position matches the given string,
* and subsequent parameters are also matched, then set the parameter values,
* remove the arguments from the list, and return true. Otherwise, return false. */
bool
read
(
int
pos
,
const
std
::
string
&
str
);
bool
read
(
int
pos
,
const
std
::
string
&
str
,
Parameter
value1
);
bool
read
(
int
pos
,
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
);
bool
read
(
int
pos
,
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
,
Parameter
value3
);
bool
read
(
int
pos
,
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
,
Parameter
value3
,
Parameter
value4
);
bool
read
(
int
pos
,
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
,
Parameter
value3
,
Parameter
value4
,
Parameter
value5
);
bool
read
(
int
pos
,
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
,
Parameter
value3
,
Parameter
value4
,
Parameter
value5
,
Parameter
value6
);
bool
read
(
int
pos
,
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
,
Parameter
value3
,
Parameter
value4
,
Parameter
value5
,
Parameter
value6
,
Parameter
value7
);
bool
read
(
int
pos
,
const
std
::
string
&
str
,
Parameter
value1
,
Parameter
value2
,
Parameter
value3
,
Parameter
value4
,
Parameter
value5
,
Parameter
value6
,
Parameter
value7
,
Parameter
value8
);
enum
ErrorSeverity
{
BENIGN
=
0
,
CRITICAL
=
1
};
typedef
std
::
map
<
std
::
string
,
ErrorSeverity
>
ErrorMessageMap
;
/** Return the error flag, true if an error has occurred when reading arguments. */
bool
errors
(
ErrorSeverity
severity
=
BENIGN
)
const
;
/** Report an error message by adding to the ErrorMessageMap. */
void
reportError
(
const
std
::
string
&
message
,
ErrorSeverity
severity
=
CRITICAL
);
/** For each remaining option, report it as unrecognized. */
void
reportRemainingOptionsAsUnrecognized
(
ErrorSeverity
severity
=
BENIGN
);
/** Return the error message, if any has occurred. */
ErrorMessageMap
&
getErrorMessageMap
()
{
return
_errorMessageMap
;
}
/** Return the error message, if any has occurred. */
const
ErrorMessageMap
&
getErrorMessageMap
()
const
{
return
_errorMessageMap
;
}
/** Write error messages to the given ostream, if at or above the given severity. */
void
writeErrorMessages
(
std
::
ostream
&
output
,
ErrorSeverity
sevrity
=
BENIGN
);
/** This convenience method handles help requests on the command line.
* Return the type(s) of help requested. The return value of this
* function is suitable for passing into getApplicationUsage()->write().
* If ApplicationUsage::NO_HELP is returned then no help commandline option
* was found on the command line. */
ApplicationUsage
::
Type
readHelpType
();
protected:
int
*
_argc
;
char
**
_argv
;
ErrorMessageMap
_errorMessageMap
;
ref_ptr
<
ApplicationUsage
>
_usage
;
};
}
#endif
lib/mac64/include/osg/Array
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_ARRAY
#define OSG_ARRAY 1
#include
<osg/MixinVector>
#include
<osg/Vec2>
#include
<osg/Vec3>
#include
<osg/Vec4>
#include
<osg/Vec2d>
#include
<osg/Vec3d>
#include
<osg/Vec4d>
#include
<osg/Vec4ub>
#include
<osg/Vec2s>
#include
<osg/Vec3s>
#include
<osg/Vec4s>
#include
<osg/Vec2b>
#include
<osg/Vec3b>
#include
<osg/Vec4b>
#include
<osg/Matrix>
#include
<osg/BufferObject>
#include
<osg/Object>
#include
<osg/GL>
namespace
osg
{
class
ArrayVisitor
;
class
ConstArrayVisitor
;
class
ValueVisitor
;
class
ConstValueVisitor
;
class
OSG_EXPORT
Array
:
public
BufferData
{
public:
enum
Type
{
ArrayType
=
0
,
ByteArrayType
=
1
,
ShortArrayType
=
2
,
IntArrayType
=
3
,
UByteArrayType
=
4
,
UShortArrayType
=
5
,
UIntArrayType
=
6
,
Vec4ubArrayType
=
7
,
FloatArrayType
=
8
,
Vec2ArrayType
=
9
,
Vec3ArrayType
=
10
,
Vec4ArrayType
=
11
,
Vec2sArrayType
=
12
,
Vec3sArrayType
=
13
,
Vec4sArrayType
=
14
,
Vec2bArrayType
=
15
,
Vec3bArrayType
=
16
,
Vec4bArrayType
=
17
,
DoubleArrayType
=
18
,
Vec2dArrayType
=
19
,
Vec3dArrayType
=
20
,
Vec4dArrayType
=
21
,
MatrixArrayType
=
22
};
Array
(
Type
arrayType
=
ArrayType
,
GLint
dataSize
=
0
,
GLenum
dataType
=
0
)
:
_arrayType
(
arrayType
),
_dataSize
(
dataSize
),
_dataType
(
dataType
)
{}
Array
(
const
Array
&
array
,
const
CopyOp
&
copyop
=
CopyOp
::
SHALLOW_COPY
)
:
BufferData
(
array
,
copyop
),
_arrayType
(
array
.
_arrayType
),
_dataSize
(
array
.
_dataSize
),
_dataType
(
array
.
_dataType
)
{}
virtual
bool
isSameKindAs
(
const
Object
*
obj
)
const
{
return
dynamic_cast
<
const
Array
*>
(
obj
)
!=
NULL
;
}
virtual
const
char
*
libraryName
()
const
{
return
"osg"
;
}
virtual
const
char
*
className
()
const
;
virtual
void
accept
(
ArrayVisitor
&
)
=
0
;
virtual
void
accept
(
ConstArrayVisitor
&
)
const
=
0
;
virtual
void
accept
(
unsigned
int
index
,
ValueVisitor
&
)
=
0
;
virtual
void
accept
(
unsigned
int
index
,
ConstValueVisitor
&
)
const
=
0
;
/** Return -1 if lhs element is less than rhs element, 0 if equal,
* 1 if lhs element is greater than rhs element. */
virtual
int
compare
(
unsigned
int
lhs
,
unsigned
int
rhs
)
const
=
0
;
Type
getType
()
const
{
return
_arrayType
;
}
GLint
getDataSize
()
const
{
return
_dataSize
;
}
GLenum
getDataType
()
const
{
return
_dataType
;
}
virtual
const
GLvoid
*
getDataPointer
()
const
=
0
;
virtual
unsigned
int
getTotalDataSize
()
const
=
0
;
virtual
unsigned
int
getNumElements
()
const
=
0
;
/** Frees unused space on this vector - i.e. the difference between size() and max_size() of the underlying vector.*/
virtual
void
trim
()
{}
/** Set the VertexBufferObject.*/
inline
void
setVertexBufferObject
(
osg
::
VertexBufferObject
*
vbo
)
{
setBufferObject
(
vbo
);
}
/** Get the VertexBufferObject. If no VBO is assigned returns NULL*/
inline
osg
::
VertexBufferObject
*
getVertexBufferObject
()
{
return
dynamic_cast
<
osg
::
VertexBufferObject
*>
(
_bufferObject
.
get
());
}
/** Get the const VertexBufferObject. If no VBO is assigned returns NULL*/
inline
const
osg
::
VertexBufferObject
*
getVertexBufferObject
()
const
{
return
dynamic_cast
<
const
osg
::
VertexBufferObject
*>
(
_bufferObject
.
get
());
}
protected:
virtual
~
Array
()
{}
Type
_arrayType
;
GLint
_dataSize
;
GLenum
_dataType
;
};
template
<
typename
T
,
Array
::
Type
ARRAYTYPE
,
int
DataSize
,
int
DataType
>
class
TemplateArray
:
public
Array
,
public
MixinVector
<
T
>
{
public:
TemplateArray
()
:
Array
(
ARRAYTYPE
,
DataSize
,
DataType
)
{}
TemplateArray
(
const
TemplateArray
&
ta
,
const
CopyOp
&
copyop
=
CopyOp
::
SHALLOW_COPY
)
:
Array
(
ta
,
copyop
),
MixinVector
<
T
>
(
ta
)
{}
TemplateArray
(
unsigned
int
no
)
:
Array
(
ARRAYTYPE
,
DataSize
,
DataType
),
MixinVector
<
T
>
(
no
)
{}
TemplateArray
(
unsigned
int
no
,
const
T
*
ptr
)
:
Array
(
ARRAYTYPE
,
DataSize
,
DataType
),
MixinVector
<
T
>
(
ptr
,
ptr
+
no
)
{}
template
<
class
InputIterator
>
TemplateArray
(
InputIterator
first
,
InputIterator
last
)
:
Array
(
ARRAYTYPE
,
DataSize
,
DataType
),
MixinVector
<
T
>
(
first
,
last
)
{}
TemplateArray
&
operator
=
(
const
TemplateArray
&
array
)
{
if
(
this
==&
array
)
return
*
this
;
this
->
assign
(
array
.
begin
(),
array
.
end
());
return
*
this
;
}
virtual
Object
*
cloneType
()
const
{
return
new
TemplateArray
();
}
virtual
Object
*
clone
(
const
CopyOp
&
copyop
)
const
{
return
new
TemplateArray
(
*
this
,
copyop
);
}
inline
virtual
void
accept
(
ArrayVisitor
&
av
);
inline
virtual
void
accept
(
ConstArrayVisitor
&
av
)
const
;
inline
virtual
void
accept
(
unsigned
int
index
,
ValueVisitor
&
vv
);
inline
virtual
void
accept
(
unsigned
int
index
,
ConstValueVisitor
&
vv
)
const
;
virtual
int
compare
(
unsigned
int
lhs
,
unsigned
int
rhs
)
const
{
const
T
&
elem_lhs
=
(
*
this
)[
lhs
];
const
T
&
elem_rhs
=
(
*
this
)[
rhs
];
if
(
elem_lhs
<
elem_rhs
)
return
-
1
;
if
(
elem_rhs
<
elem_lhs
)
return
1
;
return
0
;
}
/** Frees unused space on this vector - i.e. the difference between size() and max_size() of the underlying vector.*/
virtual
void
trim
()
{
MixinVector
<
T
>
(
*
this
).
swap
(
*
this
);
}
virtual
const
GLvoid
*
getDataPointer
()
const
{
if
(
!
this
->
empty
())
return
&
this
->
front
();
else
return
0
;
}
virtual
unsigned
int
getTotalDataSize
()
const
{
return
static_cast
<
unsigned
int
>
(
this
->
size
()
*
sizeof
(
T
));
}
virtual
unsigned
int
getNumElements
()
const
{
return
static_cast
<
unsigned
int
>
(
this
->
size
());
}
typedef
T
ElementDataType
;
// expose T
protected:
virtual
~
TemplateArray
()
{}
};
class
OSG_EXPORT
IndexArray
:
public
Array
{
public:
IndexArray
(
Type
arrayType
=
ArrayType
,
GLint
dataSize
=
0
,
GLenum
dataType
=
0
)
:
Array
(
arrayType
,
dataSize
,
dataType
)
{}
IndexArray
(
const
Array
&
array
,
const
CopyOp
&
copyop
=
CopyOp
::
SHALLOW_COPY
)
:
Array
(
array
,
copyop
)
{}
virtual
bool
isSameKindAs
(
const
Object
*
obj
)
const
{
return
dynamic_cast
<
const
IndexArray
*>
(
obj
)
!=
NULL
;
}
virtual
unsigned
int
index
(
unsigned
int
pos
)
const
=
0
;
protected:
virtual
~
IndexArray
()
{}
};
template
<
typename
T
,
Array
::
Type
ARRAYTYPE
,
int
DataSize
,
int
DataType
>
class
TemplateIndexArray
:
public
IndexArray
,
public
MixinVector
<
T
>
{
public:
TemplateIndexArray
()
:
IndexArray
(
ARRAYTYPE
,
DataSize
,
DataType
)
{}
TemplateIndexArray
(
const
TemplateIndexArray
&
ta
,
const
CopyOp
&
copyop
=
CopyOp
::
SHALLOW_COPY
)
:
IndexArray
(
ta
,
copyop
),
MixinVector
<
T
>
(
ta
)
{}
TemplateIndexArray
(
unsigned
int
no
)
:
IndexArray
(
ARRAYTYPE
,
DataSize
,
DataType
),
MixinVector
<
T
>
(
no
)
{}
TemplateIndexArray
(
unsigned
int
no
,
T
*
ptr
)
:
IndexArray
(
ARRAYTYPE
,
DataSize
,
DataType
),
MixinVector
<
T
>
(
ptr
,
ptr
+
no
)
{}
template
<
class
InputIterator
>
TemplateIndexArray
(
InputIterator
first
,
InputIterator
last
)
:
IndexArray
(
ARRAYTYPE
,
DataSize
,
DataType
),
MixinVector
<
T
>
(
first
,
last
)
{}
TemplateIndexArray
&
operator
=
(
const
TemplateIndexArray
&
array
)
{
if
(
this
==&
array
)
return
*
this
;
this
->
assign
(
array
.
begin
(),
array
.
end
());
return
*
this
;
}
virtual
Object
*
cloneType
()
const
{
return
new
TemplateIndexArray
();
}
virtual
Object
*
clone
(
const
CopyOp
&
copyop
)
const
{
return
new
TemplateIndexArray
(
*
this
,
copyop
);
}
inline
virtual
void
accept
(
ArrayVisitor
&
av
);
inline
virtual
void
accept
(
ConstArrayVisitor
&
av
)
const
;
inline
virtual
void
accept
(
unsigned
int
index
,
ValueVisitor
&
vv
);
inline
virtual
void
accept
(
unsigned
int
index
,
ConstValueVisitor
&
vv
)
const
;
virtual
int
compare
(
unsigned
int
lhs
,
unsigned
int
rhs
)
const
{
const
T
&
elem_lhs
=
(
*
this
)[
lhs
];
const
T
&
elem_rhs
=
(
*
this
)[
rhs
];
if
(
elem_lhs
<
elem_rhs
)
return
-
1
;
if
(
elem_rhs
<
elem_lhs
)
return
1
;
return
0
;
}
/** Frees unused space on this vector - i.e. the difference between size() and max_size() of the underlying vector.*/
virtual
void
trim
()
{
MixinVector
<
T
>
(
*
this
).
swap
(
*
this
);
}
virtual
const
GLvoid
*
getDataPointer
()
const
{
if
(
!
this
->
empty
())
return
&
this
->
front
();
else
return
0
;
}
virtual
unsigned
int
getTotalDataSize
()
const
{
return
static_cast
<
unsigned
int
>
(
this
->
size
()
*
sizeof
(
T
));
}
virtual
unsigned
int
getNumElements
()
const
{
return
static_cast
<
unsigned
int
>
(
this
->
size
());
}
virtual
unsigned
int
index
(
unsigned
int
pos
)
const
{
return
(
*
this
)[
pos
];
}
typedef
T
ElementDataType
;
// expose T
protected:
virtual
~
TemplateIndexArray
()
{}
};
typedef
TemplateIndexArray
<
GLbyte
,
Array
::
ByteArrayType
,
1
,
GL_BYTE
>
ByteArray
;
typedef
TemplateIndexArray
<
GLshort
,
Array
::
ShortArrayType
,
1
,
GL_SHORT
>
ShortArray
;
typedef
TemplateIndexArray
<
GLint
,
Array
::
IntArrayType
,
1
,
GL_INT
>
IntArray
;
typedef
TemplateIndexArray
<
GLubyte
,
Array
::
UByteArrayType
,
1
,
GL_UNSIGNED_BYTE
>
UByteArray
;
typedef
TemplateIndexArray
<
GLushort
,
Array
::
UShortArrayType
,
1
,
GL_UNSIGNED_SHORT
>
UShortArray
;
typedef
TemplateIndexArray
<
GLuint
,
Array
::
UIntArrayType
,
1
,
GL_UNSIGNED_INT
>
UIntArray
;
typedef
TemplateArray
<
GLfloat
,
Array
::
FloatArrayType
,
1
,
GL_FLOAT
>
FloatArray
;
typedef
TemplateArray
<
Vec2
,
Array
::
Vec2ArrayType
,
2
,
GL_FLOAT
>
Vec2Array
;
typedef
TemplateArray
<
Vec3
,
Array
::
Vec3ArrayType
,
3
,
GL_FLOAT
>
Vec3Array
;
typedef
TemplateArray
<
Vec4
,
Array
::
Vec4ArrayType
,
4
,
GL_FLOAT
>
Vec4Array
;
typedef
TemplateArray
<
Vec4ub
,
Array
::
Vec4ubArrayType
,
4
,
GL_UNSIGNED_BYTE
>
Vec4ubArray
;
typedef
TemplateArray
<
Vec2s
,
Array
::
Vec2sArrayType
,
2
,
GL_SHORT
>
Vec2sArray
;
typedef
TemplateArray
<
Vec3s
,
Array
::
Vec3sArrayType
,
3
,
GL_SHORT
>
Vec3sArray
;
typedef
TemplateArray
<
Vec4s
,
Array
::
Vec4sArrayType
,
4
,
GL_SHORT
>
Vec4sArray
;
typedef
TemplateArray
<
Vec2b
,
Array
::
Vec2bArrayType
,
2
,
GL_BYTE
>
Vec2bArray
;
typedef
TemplateArray
<
Vec3b
,
Array
::
Vec3bArrayType
,
3
,
GL_BYTE
>
Vec3bArray
;
typedef
TemplateArray
<
Vec4b
,
Array
::
Vec4bArrayType
,
4
,
GL_BYTE
>
Vec4bArray
;
typedef
TemplateArray
<
GLdouble
,
Array
::
DoubleArrayType
,
1
,
GL_DOUBLE
>
DoubleArray
;
typedef
TemplateArray
<
Vec2d
,
Array
::
Vec2dArrayType
,
2
,
GL_DOUBLE
>
Vec2dArray
;
typedef
TemplateArray
<
Vec3d
,
Array
::
Vec3dArrayType
,
3
,
GL_DOUBLE
>
Vec3dArray
;
typedef
TemplateArray
<
Vec4d
,
Array
::
Vec4dArrayType
,
4
,
GL_DOUBLE
>
Vec4dArray
;
typedef
TemplateArray
<
Matrixf
,
Array
::
MatrixArrayType
,
16
,
GL_FLOAT
>
MatrixfArray
;
class
ArrayVisitor
{
public:
ArrayVisitor
()
{}
virtual
~
ArrayVisitor
()
{}
virtual
void
apply
(
Array
&
)
{}
virtual
void
apply
(
ByteArray
&
)
{}
virtual
void
apply
(
ShortArray
&
)
{}
virtual
void
apply
(
IntArray
&
)
{}
virtual
void
apply
(
UByteArray
&
)
{}
virtual
void
apply
(
UShortArray
&
)
{}
virtual
void
apply
(
UIntArray
&
)
{}
virtual
void
apply
(
FloatArray
&
)
{}
virtual
void
apply
(
DoubleArray
&
)
{}
virtual
void
apply
(
Vec2Array
&
)
{}
virtual
void
apply
(
Vec3Array
&
)
{}
virtual
void
apply
(
Vec4Array
&
)
{}
virtual
void
apply
(
Vec4ubArray
&
)
{}
virtual
void
apply
(
Vec2bArray
&
)
{}
virtual
void
apply
(
Vec3bArray
&
)
{}
virtual
void
apply
(
Vec4bArray
&
)
{}
virtual
void
apply
(
Vec2sArray
&
)
{}
virtual
void
apply
(
Vec3sArray
&
)
{}
virtual
void
apply
(
Vec4sArray
&
)
{}
virtual
void
apply
(
Vec2dArray
&
)
{}
virtual
void
apply
(
Vec3dArray
&
)
{}
virtual
void
apply
(
Vec4dArray
&
)
{}
virtual
void
apply
(
MatrixfArray
&
)
{}
};
class
ConstArrayVisitor
{
public:
ConstArrayVisitor
()
{}
virtual
~
ConstArrayVisitor
()
{}
virtual
void
apply
(
const
Array
&
)
{}
virtual
void
apply
(
const
ByteArray
&
)
{}
virtual
void
apply
(
const
ShortArray
&
)
{}
virtual
void
apply
(
const
IntArray
&
)
{}
virtual
void
apply
(
const
UByteArray
&
)
{}
virtual
void
apply
(
const
UShortArray
&
)
{}
virtual
void
apply
(
const
UIntArray
&
)
{}
virtual
void
apply
(
const
FloatArray
&
)
{}
virtual
void
apply
(
const
DoubleArray
&
)
{}
virtual
void
apply
(
const
Vec2Array
&
)
{}
virtual
void
apply
(
const
Vec3Array
&
)
{}
virtual
void
apply
(
const
Vec4Array
&
)
{}
virtual
void
apply
(
const
Vec4ubArray
&
)
{}
virtual
void
apply
(
const
Vec2bArray
&
)
{}
virtual
void
apply
(
const
Vec3bArray
&
)
{}
virtual
void
apply
(
const
Vec4bArray
&
)
{}
virtual
void
apply
(
const
Vec2sArray
&
)
{}
virtual
void
apply
(
const
Vec3sArray
&
)
{}
virtual
void
apply
(
const
Vec4sArray
&
)
{}
virtual
void
apply
(
const
Vec2dArray
&
)
{}
virtual
void
apply
(
const
Vec3dArray
&
)
{}
virtual
void
apply
(
const
Vec4dArray
&
)
{}
virtual
void
apply
(
const
MatrixfArray
&
)
{}
};
class
ValueVisitor
{
public:
ValueVisitor
()
{}
virtual
~
ValueVisitor
()
{}
virtual
void
apply
(
GLbyte
&
)
{}
virtual
void
apply
(
GLshort
&
)
{}
virtual
void
apply
(
GLint
&
)
{}
virtual
void
apply
(
GLushort
&
)
{}
virtual
void
apply
(
GLubyte
&
)
{}
virtual
void
apply
(
GLuint
&
)
{}
virtual
void
apply
(
GLfloat
&
)
{}
virtual
void
apply
(
GLdouble
&
)
{}
virtual
void
apply
(
Vec2
&
)
{}
virtual
void
apply
(
Vec3
&
)
{}
virtual
void
apply
(
Vec4
&
)
{}
virtual
void
apply
(
Vec4ub
&
)
{}
virtual
void
apply
(
Vec2b
&
)
{}
virtual
void
apply
(
Vec3b
&
)
{}
virtual
void
apply
(
Vec4b
&
)
{}
virtual
void
apply
(
Vec2s
&
)
{}
virtual
void
apply
(
Vec3s
&
)
{}
virtual
void
apply
(
Vec4s
&
)
{}
virtual
void
apply
(
Vec2d
&
)
{}
virtual
void
apply
(
Vec3d
&
)
{}
virtual
void
apply
(
Vec4d
&
)
{}
virtual
void
apply
(
Matrixf
&
)
{}
};
class
ConstValueVisitor
{
public:
ConstValueVisitor
()
{}
virtual
~
ConstValueVisitor
()
{}
virtual
void
apply
(
const
GLbyte
&
)
{}
virtual
void
apply
(
const
GLshort
&
)
{}
virtual
void
apply
(
const
GLint
&
)
{}
virtual
void
apply
(
const
GLushort
&
)
{}
virtual
void
apply
(
const
GLubyte
&
)
{}
virtual
void
apply
(
const
GLuint
&
)
{}
virtual
void
apply
(
const
GLfloat
&
)
{}
virtual
void
apply
(
const
GLdouble
&
)
{}
virtual
void
apply
(
const
Vec4ub
&
)
{}
virtual
void
apply
(
const
Vec2
&
)
{}
virtual
void
apply
(
const
Vec3
&
)
{}
virtual
void
apply
(
const
Vec4
&
)
{}
virtual
void
apply
(
const
Vec2b
&
)
{}
virtual
void
apply
(
const
Vec3b
&
)
{}
virtual
void
apply
(
const
Vec4b
&
)
{}
virtual
void
apply
(
const
Vec2s
&
)
{}
virtual
void
apply
(
const
Vec3s
&
)
{}
virtual
void
apply
(
const
Vec4s
&
)
{}
virtual
void
apply
(
const
Vec2d
&
)
{}
virtual
void
apply
(
const
Vec3d
&
)
{}
virtual
void
apply
(
const
Vec4d
&
)
{}
virtual
void
apply
(
const
Matrixf
&
)
{}
};
template
<
typename
T
,
Array
::
Type
ARRAYTYPE
,
int
DataSize
,
int
DataType
>
inline
void
TemplateArray
<
T
,
ARRAYTYPE
,
DataSize
,
DataType
>::
accept
(
ArrayVisitor
&
av
)
{
av
.
apply
(
*
this
);
}
template
<
typename
T
,
Array
::
Type
ARRAYTYPE
,
int
DataSize
,
int
DataType
>
inline
void
TemplateArray
<
T
,
ARRAYTYPE
,
DataSize
,
DataType
>::
accept
(
ConstArrayVisitor
&
av
)
const
{
av
.
apply
(
*
this
);
}
template
<
typename
T
,
Array
::
Type
ARRAYTYPE
,
int
DataSize
,
int
DataType
>
inline
void
TemplateArray
<
T
,
ARRAYTYPE
,
DataSize
,
DataType
>::
accept
(
unsigned
int
index
,
ValueVisitor
&
vv
)
{
vv
.
apply
(
(
*
this
)[
index
]
);
}
template
<
typename
T
,
Array
::
Type
ARRAYTYPE
,
int
DataSize
,
int
DataType
>
inline
void
TemplateArray
<
T
,
ARRAYTYPE
,
DataSize
,
DataType
>::
accept
(
unsigned
int
index
,
ConstValueVisitor
&
vv
)
const
{
vv
.
apply
(
(
*
this
)[
index
]
);}
template
<
typename
T
,
Array
::
Type
ARRAYTYPE
,
int
DataSize
,
int
DataType
>
inline
void
TemplateIndexArray
<
T
,
ARRAYTYPE
,
DataSize
,
DataType
>::
accept
(
ArrayVisitor
&
av
)
{
av
.
apply
(
*
this
);
}
template
<
typename
T
,
Array
::
Type
ARRAYTYPE
,
int
DataSize
,
int
DataType
>
inline
void
TemplateIndexArray
<
T
,
ARRAYTYPE
,
DataSize
,
DataType
>::
accept
(
ConstArrayVisitor
&
av
)
const
{
av
.
apply
(
*
this
);
}
template
<
typename
T
,
Array
::
Type
ARRAYTYPE
,
int
DataSize
,
int
DataType
>
inline
void
TemplateIndexArray
<
T
,
ARRAYTYPE
,
DataSize
,
DataType
>::
accept
(
unsigned
int
index
,
ValueVisitor
&
vv
)
{
vv
.
apply
(
(
*
this
)[
index
]
);
}
template
<
typename
T
,
Array
::
Type
ARRAYTYPE
,
int
DataSize
,
int
DataType
>
inline
void
TemplateIndexArray
<
T
,
ARRAYTYPE
,
DataSize
,
DataType
>::
accept
(
unsigned
int
index
,
ConstValueVisitor
&
vv
)
const
{
vv
.
apply
(
(
*
this
)[
index
]
);}
}
#endif
lib/mac64/include/osg/ArrayDispatchers
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_ArrayDispatchers
#define OSG_ArrayDispatchers 1
#include
<osg/ref_ptr>
#include
<osg/Array>
#include
<osg/Matrixd>
#include
<osg/GLBeginEndAdapter>
namespace
osg
{
// forward declare
class
State
;
class
AttributeDispatchMap
;
struct
AttributeDispatch
:
public
osg
::
Referenced
{
virtual
void
assign
(
const
GLvoid
*
,
const
IndexArray
*
)
{}
virtual
void
operator
()
(
unsigned
int
)
{};
};
/** Helper class for managing the dispatch to OpenGL of various attribute arrays such as stored in osg::Geometry.*/
class
OSG_EXPORT
ArrayDispatchers
:
public
osg
::
Referenced
{
public:
ArrayDispatchers
();
~
ArrayDispatchers
();
void
setState
(
osg
::
State
*
state
);
AttributeDispatch
*
vertexDispatcher
(
Array
*
array
,
IndexArray
*
indices
);
AttributeDispatch
*
normalDispatcher
(
Array
*
array
,
IndexArray
*
indices
);
AttributeDispatch
*
colorDispatcher
(
Array
*
array
,
IndexArray
*
indices
);
AttributeDispatch
*
secondaryColorDispatcher
(
Array
*
array
,
IndexArray
*
indices
);
AttributeDispatch
*
fogCoordDispatcher
(
Array
*
array
,
IndexArray
*
indices
);
AttributeDispatch
*
texCoordDispatcher
(
unsigned
int
unit
,
Array
*
array
,
IndexArray
*
indices
);
AttributeDispatch
*
vertexAttribDispatcher
(
unsigned
int
unit
,
Array
*
array
,
IndexArray
*
indices
);
void
reset
();
void
setUseGLBeginEndAdapter
(
bool
flag
)
{
_useGLBeginEndAdapter
=
flag
;
}
bool
getUseGLBeginEndAdapter
()
const
{
return
_useGLBeginEndAdapter
;
}
void
setUseVertexAttribAlias
(
bool
flag
)
{
_useVertexAttribAlias
=
flag
;
}
bool
getUseVertexAttribAlias
()
const
{
return
_useVertexAttribAlias
;
}
void
activate
(
unsigned
int
binding
,
AttributeDispatch
*
at
)
{
if
(
at
)
_activeDispatchList
[
binding
].
push_back
(
at
);
}
void
activateVertexArray
(
unsigned
int
binding
,
osg
::
Array
*
array
,
osg
::
IndexArray
*
indices
)
{
if
(
binding
&&
array
)
activate
(
binding
,
vertexDispatcher
(
array
,
indices
));
}
void
activateColorArray
(
unsigned
int
binding
,
osg
::
Array
*
array
,
osg
::
IndexArray
*
indices
)
{
if
(
binding
&&
array
)
activate
(
binding
,
colorDispatcher
(
array
,
indices
));
}
void
activateNormalArray
(
unsigned
int
binding
,
osg
::
Array
*
array
,
osg
::
IndexArray
*
indices
)
{
if
(
binding
&&
array
)
activate
(
binding
,
normalDispatcher
(
array
,
indices
));
}
void
activateSecondaryColorArray
(
unsigned
int
binding
,
osg
::
Array
*
array
,
osg
::
IndexArray
*
indices
)
{
if
(
binding
&&
array
)
activate
(
binding
,
secondaryColorDispatcher
(
array
,
indices
));
}
void
activateFogCoordArray
(
unsigned
int
binding
,
osg
::
Array
*
array
,
osg
::
IndexArray
*
indices
)
{
if
(
binding
&&
array
)
activate
(
binding
,
fogCoordDispatcher
(
array
,
indices
));
}
void
activateTexCoordArray
(
unsigned
int
binding
,
unsigned
int
unit
,
osg
::
Array
*
array
,
osg
::
IndexArray
*
indices
)
{
if
(
binding
&&
array
)
activate
(
binding
,
texCoordDispatcher
(
unit
,
array
,
indices
));
}
void
activateVertexAttribArray
(
unsigned
int
binding
,
unsigned
int
unit
,
osg
::
Array
*
array
,
osg
::
IndexArray
*
indices
)
{
if
(
binding
&&
array
)
activate
(
binding
,
vertexAttribDispatcher
(
unit
,
array
,
indices
));
}
void
dispatch
(
unsigned
int
binding
,
unsigned
int
index
)
{
AttributeDispatchList
&
ad
=
_activeDispatchList
[
binding
];
for
(
AttributeDispatchList
::
iterator
itr
=
ad
.
begin
();
itr
!=
ad
.
end
();
++
itr
)
{
(
*
(
*
itr
))(
index
);
}
}
bool
active
(
unsigned
int
binding
)
const
{
return
!
_activeDispatchList
[
binding
].
empty
();
}
void
Begin
(
GLenum
mode
)
{
#ifdef OSG_GL1_AVAILABLE
if
(
_useGLBeginEndAdapter
)
_glBeginEndAdapter
->
Begin
(
mode
);
else
::
glBegin
(
mode
);
#else
_glBeginEndAdapter
->
Begin
(
mode
);
#endif
}
void
End
()
{
#ifdef OSG_GL1_AVAILABLE
if
(
_useGLBeginEndAdapter
)
_glBeginEndAdapter
->
End
();
else
::
glEnd
();
#else
_glBeginEndAdapter
->
End
();
#endif
}
protected:
void
init
();
void
assignTexCoordDispatchers
(
unsigned
int
unit
);
void
assignVertexAttribDispatchers
(
unsigned
int
unit
);
bool
_initialized
;
State
*
_state
;
GLBeginEndAdapter
*
_glBeginEndAdapter
;
AttributeDispatchMap
*
_vertexDispatchers
;
AttributeDispatchMap
*
_normalDispatchers
;
AttributeDispatchMap
*
_colorDispatchers
;
AttributeDispatchMap
*
_secondaryColorDispatchers
;
AttributeDispatchMap
*
_fogCoordDispatchers
;
typedef
std
::
vector
<
AttributeDispatchMap
*>
AttributeDispatchMapList
;
AttributeDispatchMapList
_texCoordDispatchers
;
AttributeDispatchMapList
_vertexAttribDispatchers
;
typedef
std
::
vector
<
AttributeDispatch
*>
AttributeDispatchList
;
typedef
std
::
vector
<
AttributeDispatchList
>
ActiveDispatchList
;
ActiveDispatchList
_activeDispatchList
;
bool
_useVertexAttribAlias
;
bool
_useGLBeginEndAdapter
;
};
}
#endif
lib/mac64/include/osg/AudioStream
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_AUDIOSTREAM
#define OSG_AUDIOSTREAM 1
#include
<osg/Image>
#include
<stdlib.h>
namespace
osg
{
/** Pure virtual AudioSink bass class that is used to connect the audio system with AudioStreams. */
class
OSG_EXPORT
AudioSink
:
public
osg
::
Object
{
public:
AudioSink
();
virtual
const
char
*
libraryName
()
const
{
return
"osg"
;
}
virtual
const
char
*
className
()
const
{
return
"AudioSinkInterface"
;
}
virtual
void
play
()
=
0
;
virtual
void
pause
()
=
0
;
virtual
void
stop
()
=
0
;
virtual
bool
playing
()
const
=
0
;
virtual
double
getDelay
()
const
{
return
_delay
;
}
virtual
void
setDelay
(
const
double
delay
)
{
_delay
=
delay
;
}
virtual
void
setVolume
(
float
)
{}
virtual
float
getVolume
()
const
{
return
0.0
f
;
}
private:
virtual
AudioSink
*
cloneType
()
const
{
return
0
;
}
virtual
AudioSink
*
clone
(
const
osg
::
CopyOp
&
)
const
{
return
0
;
}
double
_delay
;
};
/** Pure virtual AudioStream base class. Subclasses provide mechanism for reading/generating audio data*/
class
OSG_EXPORT
AudioStream
:
public
osg
::
Object
{
public:
AudioStream
();
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
AudioStream
(
const
AudioStream
&
audio
,
const
CopyOp
&
copyop
=
CopyOp
::
SHALLOW_COPY
);
virtual
bool
isSameKindAs
(
const
Object
*
obj
)
const
{
return
dynamic_cast
<
const
AudioStream
*>
(
obj
)
!=
0
;
}
virtual
const
char
*
libraryName
()
const
{
return
"osg"
;
}
virtual
const
char
*
className
()
const
{
return
"AudioStream"
;
}
virtual
void
setAudioSink
(
osg
::
AudioSink
*
audio_sink
)
=
0
;
virtual
void
consumeAudioBuffer
(
void
*
const
buffer
,
const
size_t
size
)
=
0
;
virtual
int
audioFrequency
()
const
=
0
;
virtual
int
audioNbChannels
()
const
=
0
;
enum
SampleFormat
{
SAMPLE_FORMAT_U8
,
SAMPLE_FORMAT_S16
,
SAMPLE_FORMAT_S24
,
SAMPLE_FORMAT_S32
,
SAMPLE_FORMAT_F32
};
virtual
SampleFormat
audioSampleFormat
()
const
=
0
;
};
}
// namespace
#endif
lib/mac64/include/osg/AutoTransform
0 → 100644
View file @
c4d7d5af
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_AUTOTRANSFORM
#define OSG_AUTOTRANSFORM 1
#include
<osg/Group>
#include
<osg/Transform>
#include
<osg/Quat>
#include
<osg/Viewport>
namespace
osg
{
/** AutoTransform is a derived form of Transform that automatically
* scales or rotates to keep its children aligned with screen coordinates.
*/
class
OSG_EXPORT
AutoTransform
:
public
Transform
{
public
:
AutoTransform
();
AutoTransform
(
const
AutoTransform
&
pat
,
const
CopyOp
&
copyop
=
CopyOp
::
SHALLOW_COPY
);
virtual
osg
::
Object
*
cloneType
()
const
{
return
new
AutoTransform
();
}
virtual
osg
::
Object
*
clone
(
const
osg
::
CopyOp
&
copyop
)
const
{
return
new
AutoTransform
(
*
this
,
copyop
);
}
virtual
bool
isSameKindAs
(
const
osg
::
Object
*
obj
)
const
{
return
dynamic_cast
<
const
AutoTransform
*>
(
obj
)
!=
NULL
;
}
virtual
const
char
*
className
()
const
{
return
"AutoTransform"
;
}
virtual
const
char
*
libraryName
()
const
{
return
"osg"
;
}
virtual
void
accept
(
NodeVisitor
&
nv
);
virtual
AutoTransform
*
asAutoTransform
()
{
return
this
;
}
virtual
const
AutoTransform
*
asAutoTransform
()
const
{
return
this
;
}
inline
void
setPosition
(
const
Vec3d
&
pos
)
{
_position
=
pos
;
_matrixDirty
=
true
;
dirtyBound
();
}
inline
const
Vec3d
&
getPosition
()
const
{
return
_position
;
}
inline
void
setRotation
(
const
Quat
&
quat
)
{
_rotation
=
quat
;
_matrixDirty
=
true
;
dirtyBound
();
}
inline
const
Quat
&
getRotation
()
const
{
return
_rotation
;
}
inline
void
setScale
(
double
scale
)
{
setScale
(
osg
::
Vec3
(
scale
,
scale
,
scale
));
}
void
setScale
(
const
Vec3d
&
scale
);
inline
const
Vec3d
&
getScale
()
const
{
return
_scale
;
}
void
setMinimumScale
(
double
minimumScale
)
{
_minimumScale
=
minimumScale
;
}
double
getMinimumScale
()
const
{
return
_minimumScale
;
}
void
setMaximumScale
(
double
maximumScale
)
{
_maximumScale
=
maximumScale
;
}
double
getMaximumScale
()
const
{
return
_maximumScale
;
}
inline
void
setPivotPoint
(
const
Vec3d
&
pivot
)
{
_pivotPoint
=
pivot
;
_matrixDirty
=
true
;
dirtyBound
();
}
inline
const
Vec3d
&
getPivotPoint
()
const
{
return
_pivotPoint
;
}
void
setAutoUpdateEyeMovementTolerance
(
float
tolerance
)
{
_autoUpdateEyeMovementTolerance
=
tolerance
;
}
float
getAutoUpdateEyeMovementTolerance
()
const
{
return
_autoUpdateEyeMovementTolerance
;
}
enum
AutoRotateMode
{
NO_ROTATION
,
ROTATE_TO_SCREEN
,
ROTATE_TO_CAMERA
,
ROTATE_TO_AXIS
};
void
setAutoRotateMode
(
AutoRotateMode
mode
);
AutoRotateMode
getAutoRotateMode
()
const
{
return
_autoRotateMode
;
}
/** Set the rotation axis for the AutoTransform's child nodes.
* Only utilized when _autoRotateMode==ROTATE_TO_AXIS. */
void
setAxis
(
const
Vec3
&
axis
);
/** Get the rotation axis. */
inline
const
Vec3
&
getAxis
()
const
{
return
_axis
;
}
/** This normal defines child Nodes' front face direction when unrotated. */
void
setNormal
(
const
Vec3
&
normal
);
/** Get the front face direction normal. */
inline
const
Vec3
&
getNormal
()
const
{
return
_normal
;
}
void
setAutoScaleToScreen
(
bool
autoScaleToScreen
)
{
_autoScaleToScreen
=
autoScaleToScreen
;
_matrixDirty
=
true
;
}
bool
getAutoScaleToScreen
()
const
{
return
_autoScaleToScreen
;
}
void
setAutoScaleTransitionWidthRatio
(
float
ratio
)
{
_autoScaleTransitionWidthRatio
=
ratio
;
}
float
getAutoScaleTransitionWidthRatio
()
const
{
return
_autoScaleTransitionWidthRatio
;
}
virtual
bool
computeLocalToWorldMatrix
(
Matrix
&
matrix
,
NodeVisitor
*
nv
)
const
;
virtual
bool
computeWorldToLocalMatrix
(
Matrix
&
matrix
,
NodeVisitor
*
nv
)
const
;
virtual
BoundingSphere
computeBound
()
const
;
protected
:
virtual
~
AutoTransform
()
{}
Vec3d
_position
;
Vec3d
_pivotPoint
;
double
_autoUpdateEyeMovementTolerance
;
AutoRotateMode
_autoRotateMode
;
bool
_autoScaleToScreen
;
mutable
Quat
_rotation
;
mutable
Vec3d
_scale
;
mutable
bool
_firstTimeToInitEyePoint
;
mutable
osg
::
Vec3
_previousEyePoint
;
mutable
osg
::
Vec3
_previousLocalUp
;
mutable
Viewport
::
value_type
_previousWidth
;
mutable
Viewport
::
value_type
_previousHeight
;
mutable
osg
::
Matrixd
_previousProjection
;
mutable
osg
::
Vec3d
_previousPosition
;
double
_minimumScale
;
double
_maximumScale
;
double
_autoScaleTransitionWidthRatio
;
void
computeMatrix
()
const
;
mutable
bool
_matrixDirty
;
mutable
osg
::
Matrixd
_cachedMatrix
;
enum
AxisAligned
{
AXIAL_ROT_X_AXIS
=
ROTATE_TO_AXIS
+
1
,
AXIAL_ROT_Y_AXIS
,
AXIAL_ROT_Z_AXIS
,
CACHE_DIRTY
};
Vec3
_axis
;
Vec3
_normal
;
// used internally as cache of which what _axis is aligned to help
// decide which method of rotation to use.
int
_cachedMode
;
Vec3
_side
;
void
updateCache
();
};
}
#endif
Prev
1
2
3
4
5
…
32
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment