Skip to content

Commit

Permalink
Merge pull request #52 from LumaPictures/pr/PXR_NS
Browse files Browse the repository at this point in the history
fixes for using alternate PXR_NS
  • Loading branch information
Krystian Ligenza authored Oct 30, 2019
2 parents c01961a + d4389b5 commit 20aa4c0
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 121 deletions.
22 changes: 0 additions & 22 deletions cmake/defaults/CXXDefaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,6 @@ set(_PXR_CXX_FLAGS ${_PXR_CXX_FLAGS} ${_PXR_CXX_WARNING_FLAGS})
# CMake list to string.
string(REPLACE ";" " " _PXR_CXX_FLAGS "${_PXR_CXX_FLAGS}")

# Set namespace configuration.
if (PXR_ENABLE_NAMESPACES)
set(PXR_USE_NAMESPACES "1")

if (PXR_SET_EXTERNAL_NAMESPACE)
set(PXR_EXTERNAL_NAMESPACE ${PXR_SET_EXTERNAL_NAMESPACE})
else()
set(PXR_EXTERNAL_NAMESPACE "pxr")
endif()

if (PXR_SET_INTERNAL_NAMESPACE)
set(PXR_INTERNAL_NAMESPACE ${PXR_SET_INTERNAL_NAMESPACE})
else()
set(PXR_INTERNAL_NAMESPACE "pxrInternal_v${PXR_MAJOR_VERSION}_${PXR_MINOR_VERSION}")
endif()

message(STATUS "C++ namespace configured to (external) ${PXR_EXTERNAL_NAMESPACE}, (internal) ${PXR_INTERNAL_NAMESPACE}")
else()
set(PXR_USE_NAMESPACES "0")
message(STATUS "C++ namespaces disabled.")
endif()

# Set Python configuration
if (PXR_ENABLE_PYTHON_SUPPORT)
set(PXR_PYTHON_SUPPORT_ENABLED "1")
Expand Down
23 changes: 12 additions & 11 deletions plugin/al/usdtransaction/AL/usd/transaction/Notice.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//
#pragma once
#include "AL/usd/transaction/Api.h"
#include <pxr/pxr.h>
#include <pxr/base/tf/notice.h>
#include <pxr/usd/usd/stage.h>

Expand All @@ -25,52 +26,52 @@ namespace transaction {
//----------------------------------------------------------------------------------------------------------------------
/// \brief This transaction notice is sent when transaction is opened.
//----------------------------------------------------------------------------------------------------------------------
class OpenNotice : public pxr::TfNotice
class OpenNotice : public PXR_NS::TfNotice
{
public:
/// \brief the ctor sets tracked by transaction
/// \param layer that transaction is tracking
AL_USD_TRANSACTION_PUBLIC
OpenNotice(const pxr::SdfLayerHandle& layer):m_layer(layer) {}
OpenNotice(const PXR_NS::SdfLayerHandle& layer):m_layer(layer) {}

/// \brief gets layer tracked by transaction
/// \return layer that transaction is tracking
inline const pxr::SdfLayerHandle& GetLayer() const { return m_layer; }
inline const PXR_NS::SdfLayerHandle& GetLayer() const { return m_layer; }
private:
pxr::SdfLayerHandle m_layer;
PXR_NS::SdfLayerHandle m_layer;
};

//----------------------------------------------------------------------------------------------------------------------
/// \brief This transaction notice is sent when transaction is closed.
//----------------------------------------------------------------------------------------------------------------------
class CloseNotice : public pxr::TfNotice
class CloseNotice : public PXR_NS::TfNotice
{
public:
/// \brief the ctor sets tracked by transaction and changed as well as resynced paths
/// \param layer that transaction is tracking
/// \param changed vector of paths that changed properties
/// \param resynced vector of topmost paths for which hierarchy has changed
inline CloseNotice(const pxr::SdfLayerHandle& layer, pxr::SdfPathVector changed, pxr::SdfPathVector resynced)
inline CloseNotice(const PXR_NS::SdfLayerHandle& layer, PXR_NS::SdfPathVector changed, PXR_NS::SdfPathVector resynced)
:m_layer(layer),m_changed(std::move(changed)),m_resynced(std::move(resynced)) {}

/// \brief gets layer tracked by transaction
/// \return layer that transaction is tracking
inline const pxr::SdfLayerHandle& GetLayer() const { return m_layer; }
inline const PXR_NS::SdfLayerHandle& GetLayer() const { return m_layer; }

/// \brief gets vector of paths that changed properties
/// \return const reference to vector of paths
inline const pxr::SdfPathVector& GetChangedInfoOnlyPaths() const { return m_changed; }
inline const PXR_NS::SdfPathVector& GetChangedInfoOnlyPaths() const { return m_changed; }

/// \brief gets vector of topmost paths for which hierarchy has changed
/// \return const reference to vector of paths
inline const pxr::SdfPathVector& GetResyncedPaths() const { return m_resynced; }
inline const PXR_NS::SdfPathVector& GetResyncedPaths() const { return m_resynced; }

/// \brief provides information if any changes were registered
/// \return true when any changes were registered, otherwise false
inline bool AnyChanges() const { return !m_changed.empty() || !m_resynced.empty(); }
private:
pxr::SdfLayerHandle m_layer;
pxr::SdfPathVector m_changed, m_resynced;
PXR_NS::SdfLayerHandle m_layer;
PXR_NS::SdfPathVector m_changed, m_resynced;
};

//----------------------------------------------------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions plugin/al/usdtransaction/AL/usd/transaction/Transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#include "AL/usd/transaction/TransactionManager.h"

#include <iostream>
using namespace pxr;
PXR_NAMESPACE_USING_DIRECTIVE

namespace AL {
namespace usd {
namespace transaction {

Transaction::Transaction(const pxr::UsdStageWeakPtr& stage, const pxr::SdfLayerHandle& layer)
Transaction::Transaction(const UsdStageWeakPtr& stage, const SdfLayerHandle& layer)
:m_manager(TransactionManager::Get(stage)), m_layer(layer) {}

//----------------------------------------------------------------------------------------------------------------------
Expand All @@ -48,4 +48,4 @@ bool Transaction::InProgress() const
} // transaction
} // usd
} // AL
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
7 changes: 4 additions & 3 deletions plugin/al/usdtransaction/AL/usd/transaction/Transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//
#pragma once
#include "AL/usd/transaction/Api.h"
#include <pxr/pxr.h>
#include <pxr/usd/usd/stage.h>

namespace AL {
Expand All @@ -36,7 +37,7 @@ class Transaction
/// \param stage that will be notified about transaction open/close
/// \param layer that will be tracked for changes
AL_USD_TRANSACTION_PUBLIC
Transaction(const pxr::UsdStageWeakPtr& stage, const pxr::SdfLayerHandle& layer);
Transaction(const PXR_NS::UsdStageWeakPtr& stage, const PXR_NS::SdfLayerHandle& layer);

/// \brief opens transaction, when transaction is opened for the first time OpenNotice is emitted and current
/// state of layer is recorded.
Expand All @@ -59,7 +60,7 @@ class Transaction

private:
TransactionManager& m_manager;
pxr::SdfLayerHandle m_layer;
PXR_NS::SdfLayerHandle m_layer;
};

//----------------------------------------------------------------------------------------------------------------------
Expand All @@ -72,7 +73,7 @@ class ScopedTransaction
/// \brief the ctor initializes transaction and opens it
/// \param stage that will be notified about transaction open/close
/// \param layer that will be tracked for changes
inline ScopedTransaction(const pxr::UsdStageWeakPtr& stage, const pxr::SdfLayerHandle& layer)
inline ScopedTransaction(const PXR_NS::UsdStageWeakPtr& stage, const PXR_NS::SdfLayerHandle& layer)
:m_transaction(stage, layer)
{
m_transaction.Open();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//
#include "AL/usd/transaction/TransactionManager.h"

using namespace pxr;
PXR_NAMESPACE_USING_DIRECTIVE

namespace AL {
namespace usd {
Expand Down Expand Up @@ -210,4 +210,4 @@ bool TransactionManager::Close(const UsdStageWeakPtr& stage, const SdfLayerHandl
} // transaction
} // usd
} // AL
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
27 changes: 14 additions & 13 deletions plugin/al/usdtransaction/AL/usd/transaction/TransactionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "AL/usd/transaction/Api.h"
#include "AL/usd/transaction/Notice.h"

#include <pxr/pxr.h>
#include <pxr/base/tf/weakPtr.h>

namespace AL {
Expand Down Expand Up @@ -44,23 +45,23 @@ class TransactionManager
/// \param layer targetted by transaction
/// \return true when transaction is in progress, otherwise false
AL_USD_TRANSACTION_PUBLIC
bool InProgress(const pxr::SdfLayerHandle& layer) const;
bool InProgress(const PXR_NS::SdfLayerHandle& layer) const;

/// \brief opens transaction, when transaction is opened for the first time OpenNotice is emitted and current
/// state of layer is recorded.
/// \note It's valid to call Open multiple times, but they need to balance Close calls
/// \param layer targetted by transaction
/// \return true on success, false when layer or stage became invalid
AL_USD_TRANSACTION_PUBLIC
bool Open(const pxr::SdfLayerHandle& layer);
bool Open(const PXR_NS::SdfLayerHandle& layer);

/// \brief closes transaction, when transaction is closed for the last time CloseNotice is emitted with change
/// information based of difference between current and recorded layer states.
/// \note It's valid to call Close multiple times, but they need to balance Open calls
/// \param layer targetted by transaction
/// \return true on success, false when layer or stage became invalid or transaction wasn't opened
AL_USD_TRANSACTION_PUBLIC
bool Close(const pxr::SdfLayerHandle& layer);
bool Close(const PXR_NS::SdfLayerHandle& layer);

/// \brief provides information whether any transaction was opened and wasn't closed yet.
/// \return true when any transaction is in progress, otherwise false
Expand All @@ -73,20 +74,20 @@ class TransactionManager
/// \param stage that is managed by TransactionManager
/// \return reference to shared TransactionManager for given stage
AL_USD_TRANSACTION_PUBLIC
static TransactionManager& Get(const pxr::UsdStageWeakPtr& stage);
static TransactionManager& Get(const PXR_NS::UsdStageWeakPtr& stage);

/// \brief provides information whether any transaction was opened and wasn't closed yet.
/// \param stage that is managed by TransactionManager
/// \return true when any transaction is in progress, otherwise false
AL_USD_TRANSACTION_PUBLIC
static bool InProgress(const pxr::UsdStageWeakPtr& stage);
static bool InProgress(const PXR_NS::UsdStageWeakPtr& stage);

/// \brief provides information whether transaction was opened and wasn't closed yet.
/// \param stage that is managed by TransactionManager
/// \param layer targetted by transaction
/// \return true when transaction is in progress, otherwise false
AL_USD_TRANSACTION_PUBLIC
static bool InProgress(const pxr::UsdStageWeakPtr& stage, const pxr::SdfLayerHandle& layer);
static bool InProgress(const PXR_NS::UsdStageWeakPtr& stage, const PXR_NS::SdfLayerHandle& layer);

/// \brief opens transaction, when transaction is opened for the first time OpenNotice is emitted and current
/// state of layer is recorded.
Expand All @@ -95,7 +96,7 @@ class TransactionManager
/// \param layer targetted by transaction
/// \return true on success, false when layer or stage became invalid
AL_USD_TRANSACTION_PUBLIC
static bool Open(const pxr::UsdStageWeakPtr& stage, const pxr::SdfLayerHandle& layer);
static bool Open(const PXR_NS::UsdStageWeakPtr& stage, const PXR_NS::SdfLayerHandle& layer);

/// \brief closes transaction, when transaction is closed for the last time CloseNotice is emitted with change
/// information based of difference between current and recorded layer states.
Expand All @@ -104,19 +105,19 @@ class TransactionManager
/// \param layer targetted by transaction
/// \return true on success, false when layer or stage became invalid or transaction wasn't opened
AL_USD_TRANSACTION_PUBLIC
static bool Close(const pxr::UsdStageWeakPtr& stage, const pxr::SdfLayerHandle& layer);
static bool Close(const PXR_NS::UsdStageWeakPtr& stage, const PXR_NS::SdfLayerHandle& layer);
private:
typedef std::map<pxr::UsdStageWeakPtr, TransactionManager> StageManagerMap;
typedef std::map<PXR_NS::UsdStageWeakPtr, TransactionManager> StageManagerMap;
static StageManagerMap& GetManagers();
private:
TransactionManager(const pxr::UsdStageWeakPtr& stage):m_stage(stage) {}
TransactionManager(const PXR_NS::UsdStageWeakPtr& stage):m_stage(stage) {}
struct TransactionData
{
pxr::SdfLayerRefPtr base;
PXR_NS::SdfLayerRefPtr base;
int count;
};
const pxr::UsdStageWeakPtr m_stage;
std::unordered_map<pxr::SdfLayer*, TransactionData> m_transactions;
const PXR_NS::UsdStageWeakPtr m_stage;
std::unordered_map<PXR_NS::SdfLayer*, TransactionData> m_transactions;
};

//----------------------------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "AL/usd/transaction/Notice.h"
#include "AL/usd/transaction/Transaction.h"

#include <pxr/pxr.h>
#include <pxr/usd/usd/stage.h>
#include <pxr/usd/usd/attribute.h>

#include <gtest/gtest.h>

using namespace AL::usd::transaction;
using namespace pxr;
PXR_NAMESPACE_USING_DIRECTIVE

//----------------------------------------------------------------------------------------------------------------------
/// \brief Test some of the functionality of the AL_USDTransaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
#include "AL/usd/transaction/Transaction.h"
#include "AL/usd/transaction/TransactionManager.h"

#include <pxr/pxr.h>
#include <pxr/usd/usd/stage.h>

#include <gtest/gtest.h>

using namespace AL::usd::transaction;
using namespace pxr;
PXR_NAMESPACE_USING_DIRECTIVE

//----------------------------------------------------------------------------------------------------------------------
/// \brief Test some of the functionality of the AL_USDTransaction
Expand Down
5 changes: 0 additions & 5 deletions plugin/pxr/cmake/macros/Public.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,6 @@ function(pxr_add_extra_plugins PLUGIN_AREAS)
endfunction() # pxr_setup_third_plugins

function(pxr_toplevel_prologue)
# Generate a namespace declaration header, pxr.h, at the top level of
# pxr at configuration time.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pxr/pxr.h.in
${CMAKE_BINARY_DIR}/include/pxr/pxr.h
)

# Create a monolithic shared library target if we should import one
# or create one.
Expand Down
60 changes: 0 additions & 60 deletions plugin/pxr/pxr/pxr.h.in

This file was deleted.

0 comments on commit 20aa4c0

Please sign in to comment.