forked from RemedyIT/taox11
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request RemedyIT#362 from jwillemsen/jwi-splitostream
Moved object and wstring/wchar ostream insertion to their own files a…
- Loading branch information
Showing
13 changed files
with
440 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @file object_ostream.h | ||
* @author Marijke Hengstmengel | ||
* | ||
* @brief CORBA C++11 Logging module | ||
* | ||
* @copyright Copyright (c) Remedy IT Expertise BV | ||
*/ | ||
|
||
#ifndef TAOX11_OBJECT_OSTREAM_H | ||
#define TAOX11_OBJECT_OSTREAM_H | ||
|
||
#include "tao/x11/object_fwd.h" | ||
#include <ostream> | ||
|
||
namespace std | ||
{ | ||
inline std::ostream& | ||
operator<< (std::ostream& _os, | ||
TAOX11_CORBA::object_reference<::TAOX11_NAMESPACE::CORBA::Object> /*_ve*/) | ||
{ | ||
return _os << "CORBA:Object"; | ||
} | ||
} | ||
|
||
#endif /* TAOX11_OBJECT_OSTREAM_H */ |
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,74 @@ | ||
/** | ||
* @file client.cpp | ||
* @author Johnny Willemsen | ||
* | ||
* @brief CORBA C++11 client application | ||
* | ||
* @copyright Copyright (c) Remedy IT Expertise BV | ||
*/ | ||
|
||
#include "testC.h" | ||
#include "testlib/taox11_testlog.h" | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
int result = 0; | ||
try | ||
{ | ||
IDL::traits<CORBA::ORB>::ref_type orb = CORBA::ORB_init(argc, argv); | ||
|
||
if (orb == nullptr) | ||
{ | ||
TAOX11_TEST_ERROR << "ERROR: CORBA::ORB_init (argc, argv) returned null ORB." | ||
<< std::endl; | ||
return 1; | ||
} | ||
|
||
IDL::traits<CORBA::Object>::ref_type obj = orb->string_to_object("file://test.ior"); | ||
|
||
if (!obj) | ||
{ | ||
TAOX11_TEST_ERROR << "ERROR: string_to_object(<ior>) returned null reference." | ||
<< std::endl; | ||
return 1; | ||
} | ||
|
||
TAOX11_TEST_DEBUG << "retrieved object reference" << std::endl; | ||
|
||
IDL::traits<Test::Hello>::ref_type hello = IDL::traits<Test::Hello>::narrow (obj); | ||
|
||
if (!hello) | ||
{ | ||
TAOX11_TEST_ERROR << "ERROR: IDL::traits<Test::Hello>::narrow (obj) returned null object." | ||
<< std::endl; | ||
return 1; | ||
} | ||
TAOX11_TEST_DEBUG << "narrowed Hello interface" << std::endl; | ||
|
||
// Test | ||
{ | ||
TAOX11_TEST_DEBUG << "Test wchar get and set." << std::endl; | ||
wchar_t const text = hello->getset_wchar (L'H'); | ||
if (text != L'H') | ||
{ | ||
TAOX11_TEST_ERROR_W << L"ERROR: hello->get_string() returned an unexpected value. " | ||
<< L"expected <H>, received <" << text << L">" << std::endl; | ||
++result; | ||
} | ||
TAOX11_TEST_DEBUG_W << L"ostream test wchar: " << text << std::endl; | ||
} | ||
|
||
TAOX11_TEST_DEBUG << "shutting down..."; | ||
hello->shutdown(); | ||
TAOX11_TEST_DEBUG << std::endl; | ||
|
||
orb->destroy (); | ||
} | ||
catch (const std::exception& e) | ||
{ | ||
TAOX11_TEST_ERROR << "exception caught: " << e << std::endl; | ||
++result; | ||
} | ||
|
||
return result; | ||
} |
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 @@ | ||
/** | ||
* @file hello.cpp | ||
* @author Mark Drijver | ||
* | ||
* @brief CORBA C++11 server application | ||
* | ||
* @copyright Copyright (c) Remedy IT Expertise BV | ||
*/ | ||
|
||
|
||
#include "hello.h" | ||
#include "testlib/taox11_testlog.h" | ||
|
||
Hello::Hello(IDL::traits<CORBA::ORB>::ref_type orb, int& result) | ||
: orb_ (std::move(orb)) | ||
, result_ (result) | ||
{ | ||
} | ||
|
||
wchar_t | ||
Hello::getset_wchar (wchar_t text) | ||
{ | ||
if (text != L'H') | ||
{ | ||
TAOX11_TEST_ERROR_W << L"ERROR: Hello::getset_wchar received an unexpected value. " | ||
<< L"expected <H>, received <" << text << L">" << std::endl; | ||
++this->result_; | ||
} | ||
return L'H'; | ||
} | ||
|
||
void Hello::shutdown () | ||
{ | ||
this->orb_->shutdown (false); | ||
} |
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,37 @@ | ||
/** | ||
* @file hello.h | ||
* @author Johnny Willemsen | ||
* | ||
* @copyright Copyright (c) Remedy IT Expertise BV | ||
*/ | ||
#ifndef HELLO_H | ||
#define HELLO_H | ||
|
||
#include "testS.h" | ||
|
||
/// Implement the Test::Hello interface | ||
class Hello final | ||
: public virtual CORBA::servant_traits<Test::Hello>::base_type | ||
{ | ||
public: | ||
/// Constructor | ||
Hello(IDL::traits<CORBA::ORB>::ref_type orb, int& result); | ||
|
||
// = The skeleton methods | ||
wchar_t getset_wchar(wchar_t text) override; | ||
|
||
void shutdown() override; | ||
|
||
private: | ||
/// Use an ORB reference to convert strings to objects and shutdown | ||
/// the application. | ||
IDL::traits<CORBA::ORB>::ref_type orb_; | ||
int &result_; | ||
|
||
Hello (const Hello&) = delete; | ||
Hello (Hello&&) = delete; | ||
Hello& operator= (const Hello&) = delete; | ||
Hello& operator= (Hello&&) = delete; | ||
}; | ||
|
||
#endif /* HELLO_H */ |
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,78 @@ | ||
#--------------------------------------------------------------------- | ||
# @file run_test.pl | ||
# @author Mark Drijver | ||
# | ||
# @copyright Copyright (c) Remedy IT Expertise BV | ||
#--------------------------------------------------------------------- | ||
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' | ||
& eval 'exec perl -S $0 $argv:q' | ||
if 0; | ||
|
||
# -*- perl -*- | ||
|
||
use lib "$ENV{ACE_ROOT}/bin"; | ||
use PerlACE::TestTarget; | ||
|
||
$status = 0; | ||
$debug_level = '0'; | ||
|
||
foreach $i (@ARGV) { | ||
if ($i eq '-debug') { | ||
$debug_level = '10'; | ||
} | ||
} | ||
|
||
my $server = PerlACE::TestTarget::create_target(2) || die "Create target 2 failed\n"; | ||
my $client = PerlACE::TestTarget::create_target(3) || die "Create target 3 failed\n"; | ||
|
||
my $iorbase = "test.ior"; | ||
my $server_iorfile = $server->LocalFile ($iorbase); | ||
my $client_iorfile = $client->LocalFile ($iorbase); | ||
$server->DeleteFile($iorbase); | ||
$client->DeleteFile($iorbase); | ||
|
||
$SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile"); | ||
$CL = $client->CreateProcess ("client", "-k file://$client_iorfile"); | ||
$server_status = $SV->Spawn (); | ||
|
||
if ($server_status != 0) { | ||
print STDERR "ERROR: server returned $server_status\n"; | ||
exit 1; | ||
} | ||
|
||
if ($server->WaitForFileTimed ($iorbase, | ||
$server->ProcessStartWaitInterval()) == -1) { | ||
print STDERR "ERROR: cannot find file <$server_iorfile>\n"; | ||
$SV->Kill (); $SV->TimedWait (1); | ||
exit 1; | ||
} | ||
|
||
if ($server->GetFile ($iorbase) == -1) { | ||
print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n"; | ||
$SV->Kill (); $SV->TimedWait (1); | ||
exit 1; | ||
} | ||
if ($client->PutFile ($iorbase) == -1) { | ||
print STDERR "ERROR: cannot set file <$client_iorfile>\n"; | ||
$SV->Kill (); $SV->TimedWait (1); | ||
exit 1; | ||
} | ||
|
||
$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval()); | ||
|
||
if ($client_status != 0) { | ||
print STDERR "ERROR: client returned $client_status\n"; | ||
$status = 1; | ||
} | ||
|
||
$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval()); | ||
|
||
if ($server_status != 0) { | ||
print STDERR "ERROR: server returned $server_status\n"; | ||
$status = 1; | ||
} | ||
|
||
$server->DeleteFile($iorbase); | ||
$client->DeleteFile($iorbase); | ||
|
||
exit $status; |
Oops, something went wrong.