-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
614 additions
and
493 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2023 Intel Corporation. All Rights Reserved. | ||
|
||
#include "software-device-info.h" | ||
#include "software-device.h" | ||
#include "librealsense-exception.h" | ||
|
||
#include <rsutils/string/from.h> | ||
|
||
|
||
namespace librealsense { | ||
|
||
|
||
software_device_info::software_device_info( std::shared_ptr< context > const & ctx ) | ||
: device_info( ctx ) | ||
, _address() // leave empty until set_device() | ||
{ | ||
} | ||
|
||
|
||
void software_device_info::set_device( std::shared_ptr< software_device > const & dev ) | ||
{ | ||
if( ! _address.empty() ) | ||
throw wrong_api_call_sequence_exception( "software_device_info already initialized" ); | ||
_dev = dev; | ||
_address = rsutils::string::from() << "software-device://" << (unsigned long long)dev.get(); | ||
} | ||
|
||
|
||
bool software_device_info::is_same_as( std::shared_ptr< const device_info > const & other ) const | ||
{ | ||
if( auto rhs = std::dynamic_pointer_cast< const software_device_info >( other ) ) | ||
return _address == rhs->_address; | ||
return false; | ||
} | ||
|
||
|
||
std::shared_ptr< device_interface > software_device_info::create_device() | ||
{ | ||
return _dev.lock(); | ||
} | ||
|
||
|
||
} // namespace librealsense |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2023 Intel Corporation. All Rights Reserved. | ||
#pragma once | ||
|
||
#include "device-info.h" | ||
|
||
|
||
namespace librealsense { | ||
|
||
|
||
class software_device; | ||
|
||
|
||
class software_device_info : public device_info | ||
{ | ||
std::weak_ptr< software_device > _dev; | ||
std::string _address; | ||
|
||
public: | ||
explicit software_device_info( std::shared_ptr< context > const & ctx ); | ||
|
||
// The usage is dictated by the rs2 APIs: rather than creating the info and then using create_device() to create the | ||
// device, it's the other way around (see rs2_context_add_software_device). | ||
// | ||
void set_device( std::shared_ptr< software_device > const & dev ); | ||
|
||
std::string get_address() const override { return _address; } | ||
|
||
bool is_same_as( std::shared_ptr< const device_info > const & other ) const override; | ||
|
||
std::shared_ptr< device_interface > create_device() override; | ||
}; | ||
|
||
|
||
} // namespace librealsense |
Oops, something went wrong.