diff --git a/.gitignore b/.gitignore index 9945c77f5..474a2d764 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ server locator publisher subscriber +reader +writer talk chatserver chatgl2client @@ -17,6 +19,8 @@ chatpollclient !**/msbuild/locator !**/msbuild/publisher !**/msbuild/subscriber +!**/msbuild/reader +!**/msbuild/writer !**/Sources/client !**/Sources/server diff --git a/cpp/C++ demos.sln b/cpp/C++ demos.sln index 45c9613e9..05080f995 100644 --- a/cpp/C++ demos.sln +++ b/cpp/C++ demos.sln @@ -411,6 +411,44 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "mtalk", "mtalk", "{B1F08922 EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "Ice\mtalk\msbuild\client\client.vcxproj", "{7A216D2F-18DC-415A-96E7-A417B1DC7FB4}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DataStorm", "DataStorm", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "clock", "clock", "{9F79C5E8-103C-4C38-8CBD-56F80EA85B09}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reader", "DataStorm\clock\msbuild\reader\reader.vcxproj", "{E9146C23-516D-4D87-A217-EDF5A08DBF04}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "writer", "DataStorm\clock\msbuild\writer\writer.vcxproj", "{D5FFCE1A-7264-42D7-AE3F-60AF35D71B03}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "keyFilter", "keyFilter", "{FE2D0F22-6A55-427B-BFF2-1B93F166757C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reader", "DataStorm\keyFilter\msbuild\reader\reader.vcxproj", "{0FA27393-6D89-4612-8170-81122C6B8936}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "writer", "DataStorm\keyFilter\msbuild\writer\writer.vcxproj", "{E7270286-71D1-4C31-A2A4-A9DBA0D28E6C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "minimal", "minimal", "{765BF359-660D-4050-9F74-E9BE9212005A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reader", "DataStorm\minimal\msbuild\reader\reader.vcxproj", "{7464DBD0-F9B8-4DCE-948E-ED4A12215689}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "writer", "DataStorm\minimal\msbuild\writer\writer.vcxproj", "{5362D3A2-6280-4C76-9C98-B2B30F6A7EC6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "node", "node", "{C769473B-134B-4FD5-8F37-F22012C08C50}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sampleFilter", "sampleFilter", "{639F8A00-F592-4CB3-BC92-0AFB9388D03F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reader", "DataStorm\node\msbuild\reader\reader.vcxproj", "{07A7881F-0E97-4855-BA2A-8253F30A5FA0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "writer", "DataStorm\node\msbuild\writer\writer.vcxproj", "{558F8E62-C7E5-4DB1-9175-925A0DCE55B7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reader", "DataStorm\sampleFilter\msbuild\reader\reader.vcxproj", "{9834D6A0-4696-4525-9BB6-D51AAF557EC1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "writer", "DataStorm\sampleFilter\msbuild\writer\writer.vcxproj", "{864A92F2-D094-45AF-8277-50F43824C4EE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "stock", "stock", "{64DF5504-2D9E-409C-A998-0881AB01FC09}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reader", "DataStorm\stock\msbuild\reader\reader.vcxproj", "{5550D94C-D162-4367-BF79-00243E79D3D1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "writer", "DataStorm\stock\msbuild\writer\writer.vcxproj", "{4362D2DF-3F07-4248-9CB4-9682B29EE0D3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -1075,6 +1113,102 @@ Global {7A216D2F-18DC-415A-96E7-A417B1DC7FB4}.Release|Win32.Build.0 = Release|Win32 {7A216D2F-18DC-415A-96E7-A417B1DC7FB4}.Release|x64.ActiveCfg = Release|x64 {7A216D2F-18DC-415A-96E7-A417B1DC7FB4}.Release|x64.Build.0 = Release|x64 + {E9146C23-516D-4D87-A217-EDF5A08DBF04}.Debug|Win32.ActiveCfg = Debug|Win32 + {E9146C23-516D-4D87-A217-EDF5A08DBF04}.Debug|Win32.Build.0 = Debug|Win32 + {E9146C23-516D-4D87-A217-EDF5A08DBF04}.Debug|x64.ActiveCfg = Debug|x64 + {E9146C23-516D-4D87-A217-EDF5A08DBF04}.Debug|x64.Build.0 = Debug|x64 + {E9146C23-516D-4D87-A217-EDF5A08DBF04}.Release|Win32.ActiveCfg = Release|Win32 + {E9146C23-516D-4D87-A217-EDF5A08DBF04}.Release|Win32.Build.0 = Release|Win32 + {E9146C23-516D-4D87-A217-EDF5A08DBF04}.Release|x64.ActiveCfg = Release|x64 + {E9146C23-516D-4D87-A217-EDF5A08DBF04}.Release|x64.Build.0 = Release|x64 + {D5FFCE1A-7264-42D7-AE3F-60AF35D71B03}.Debug|Win32.ActiveCfg = Debug|Win32 + {D5FFCE1A-7264-42D7-AE3F-60AF35D71B03}.Debug|Win32.Build.0 = Debug|Win32 + {D5FFCE1A-7264-42D7-AE3F-60AF35D71B03}.Debug|x64.ActiveCfg = Debug|x64 + {D5FFCE1A-7264-42D7-AE3F-60AF35D71B03}.Debug|x64.Build.0 = Debug|x64 + {D5FFCE1A-7264-42D7-AE3F-60AF35D71B03}.Release|Win32.ActiveCfg = Release|Win32 + {D5FFCE1A-7264-42D7-AE3F-60AF35D71B03}.Release|Win32.Build.0 = Release|Win32 + {D5FFCE1A-7264-42D7-AE3F-60AF35D71B03}.Release|x64.ActiveCfg = Release|x64 + {D5FFCE1A-7264-42D7-AE3F-60AF35D71B03}.Release|x64.Build.0 = Release|x64 + {0FA27393-6D89-4612-8170-81122C6B8936}.Debug|Win32.ActiveCfg = Debug|Win32 + {0FA27393-6D89-4612-8170-81122C6B8936}.Debug|Win32.Build.0 = Debug|Win32 + {0FA27393-6D89-4612-8170-81122C6B8936}.Debug|x64.ActiveCfg = Debug|x64 + {0FA27393-6D89-4612-8170-81122C6B8936}.Debug|x64.Build.0 = Debug|x64 + {0FA27393-6D89-4612-8170-81122C6B8936}.Release|Win32.ActiveCfg = Release|Win32 + {0FA27393-6D89-4612-8170-81122C6B8936}.Release|Win32.Build.0 = Release|Win32 + {0FA27393-6D89-4612-8170-81122C6B8936}.Release|x64.ActiveCfg = Release|x64 + {0FA27393-6D89-4612-8170-81122C6B8936}.Release|x64.Build.0 = Release|x64 + {E7270286-71D1-4C31-A2A4-A9DBA0D28E6C}.Debug|Win32.ActiveCfg = Debug|Win32 + {E7270286-71D1-4C31-A2A4-A9DBA0D28E6C}.Debug|Win32.Build.0 = Debug|Win32 + {E7270286-71D1-4C31-A2A4-A9DBA0D28E6C}.Debug|x64.ActiveCfg = Debug|x64 + {E7270286-71D1-4C31-A2A4-A9DBA0D28E6C}.Debug|x64.Build.0 = Debug|x64 + {E7270286-71D1-4C31-A2A4-A9DBA0D28E6C}.Release|Win32.ActiveCfg = Release|Win32 + {E7270286-71D1-4C31-A2A4-A9DBA0D28E6C}.Release|Win32.Build.0 = Release|Win32 + {E7270286-71D1-4C31-A2A4-A9DBA0D28E6C}.Release|x64.ActiveCfg = Release|x64 + {E7270286-71D1-4C31-A2A4-A9DBA0D28E6C}.Release|x64.Build.0 = Release|x64 + {7464DBD0-F9B8-4DCE-948E-ED4A12215689}.Debug|Win32.ActiveCfg = Debug|Win32 + {7464DBD0-F9B8-4DCE-948E-ED4A12215689}.Debug|Win32.Build.0 = Debug|Win32 + {7464DBD0-F9B8-4DCE-948E-ED4A12215689}.Debug|x64.ActiveCfg = Debug|x64 + {7464DBD0-F9B8-4DCE-948E-ED4A12215689}.Debug|x64.Build.0 = Debug|x64 + {7464DBD0-F9B8-4DCE-948E-ED4A12215689}.Release|Win32.ActiveCfg = Release|Win32 + {7464DBD0-F9B8-4DCE-948E-ED4A12215689}.Release|Win32.Build.0 = Release|Win32 + {7464DBD0-F9B8-4DCE-948E-ED4A12215689}.Release|x64.ActiveCfg = Release|x64 + {7464DBD0-F9B8-4DCE-948E-ED4A12215689}.Release|x64.Build.0 = Release|x64 + {5362D3A2-6280-4C76-9C98-B2B30F6A7EC6}.Debug|Win32.ActiveCfg = Debug|Win32 + {5362D3A2-6280-4C76-9C98-B2B30F6A7EC6}.Debug|Win32.Build.0 = Debug|Win32 + {5362D3A2-6280-4C76-9C98-B2B30F6A7EC6}.Debug|x64.ActiveCfg = Debug|x64 + {5362D3A2-6280-4C76-9C98-B2B30F6A7EC6}.Debug|x64.Build.0 = Debug|x64 + {5362D3A2-6280-4C76-9C98-B2B30F6A7EC6}.Release|Win32.ActiveCfg = Release|Win32 + {5362D3A2-6280-4C76-9C98-B2B30F6A7EC6}.Release|Win32.Build.0 = Release|Win32 + {5362D3A2-6280-4C76-9C98-B2B30F6A7EC6}.Release|x64.ActiveCfg = Release|x64 + {5362D3A2-6280-4C76-9C98-B2B30F6A7EC6}.Release|x64.Build.0 = Release|x64 + {07A7881F-0E97-4855-BA2A-8253F30A5FA0}.Debug|Win32.ActiveCfg = Debug|Win32 + {07A7881F-0E97-4855-BA2A-8253F30A5FA0}.Debug|Win32.Build.0 = Debug|Win32 + {07A7881F-0E97-4855-BA2A-8253F30A5FA0}.Debug|x64.ActiveCfg = Debug|x64 + {07A7881F-0E97-4855-BA2A-8253F30A5FA0}.Debug|x64.Build.0 = Debug|x64 + {07A7881F-0E97-4855-BA2A-8253F30A5FA0}.Release|Win32.ActiveCfg = Release|Win32 + {07A7881F-0E97-4855-BA2A-8253F30A5FA0}.Release|Win32.Build.0 = Release|Win32 + {07A7881F-0E97-4855-BA2A-8253F30A5FA0}.Release|x64.ActiveCfg = Release|x64 + {07A7881F-0E97-4855-BA2A-8253F30A5FA0}.Release|x64.Build.0 = Release|x64 + {558F8E62-C7E5-4DB1-9175-925A0DCE55B7}.Debug|Win32.ActiveCfg = Debug|Win32 + {558F8E62-C7E5-4DB1-9175-925A0DCE55B7}.Debug|Win32.Build.0 = Debug|Win32 + {558F8E62-C7E5-4DB1-9175-925A0DCE55B7}.Debug|x64.ActiveCfg = Debug|x64 + {558F8E62-C7E5-4DB1-9175-925A0DCE55B7}.Debug|x64.Build.0 = Debug|x64 + {558F8E62-C7E5-4DB1-9175-925A0DCE55B7}.Release|Win32.ActiveCfg = Release|Win32 + {558F8E62-C7E5-4DB1-9175-925A0DCE55B7}.Release|Win32.Build.0 = Release|Win32 + {558F8E62-C7E5-4DB1-9175-925A0DCE55B7}.Release|x64.ActiveCfg = Release|x64 + {558F8E62-C7E5-4DB1-9175-925A0DCE55B7}.Release|x64.Build.0 = Release|x64 + {9834D6A0-4696-4525-9BB6-D51AAF557EC1}.Debug|Win32.ActiveCfg = Debug|Win32 + {9834D6A0-4696-4525-9BB6-D51AAF557EC1}.Debug|Win32.Build.0 = Debug|Win32 + {9834D6A0-4696-4525-9BB6-D51AAF557EC1}.Debug|x64.ActiveCfg = Debug|x64 + {9834D6A0-4696-4525-9BB6-D51AAF557EC1}.Debug|x64.Build.0 = Debug|x64 + {9834D6A0-4696-4525-9BB6-D51AAF557EC1}.Release|Win32.ActiveCfg = Release|Win32 + {9834D6A0-4696-4525-9BB6-D51AAF557EC1}.Release|Win32.Build.0 = Release|Win32 + {9834D6A0-4696-4525-9BB6-D51AAF557EC1}.Release|x64.ActiveCfg = Release|x64 + {9834D6A0-4696-4525-9BB6-D51AAF557EC1}.Release|x64.Build.0 = Release|x64 + {864A92F2-D094-45AF-8277-50F43824C4EE}.Debug|Win32.ActiveCfg = Debug|Win32 + {864A92F2-D094-45AF-8277-50F43824C4EE}.Debug|Win32.Build.0 = Debug|Win32 + {864A92F2-D094-45AF-8277-50F43824C4EE}.Debug|x64.ActiveCfg = Debug|x64 + {864A92F2-D094-45AF-8277-50F43824C4EE}.Debug|x64.Build.0 = Debug|x64 + {864A92F2-D094-45AF-8277-50F43824C4EE}.Release|Win32.ActiveCfg = Release|Win32 + {864A92F2-D094-45AF-8277-50F43824C4EE}.Release|Win32.Build.0 = Release|Win32 + {864A92F2-D094-45AF-8277-50F43824C4EE}.Release|x64.ActiveCfg = Release|x64 + {864A92F2-D094-45AF-8277-50F43824C4EE}.Release|x64.Build.0 = Release|x64 + {5550D94C-D162-4367-BF79-00243E79D3D1}.Debug|Win32.ActiveCfg = Debug|Win32 + {5550D94C-D162-4367-BF79-00243E79D3D1}.Debug|Win32.Build.0 = Debug|Win32 + {5550D94C-D162-4367-BF79-00243E79D3D1}.Debug|x64.ActiveCfg = Debug|x64 + {5550D94C-D162-4367-BF79-00243E79D3D1}.Debug|x64.Build.0 = Debug|x64 + {5550D94C-D162-4367-BF79-00243E79D3D1}.Release|Win32.ActiveCfg = Release|Win32 + {5550D94C-D162-4367-BF79-00243E79D3D1}.Release|Win32.Build.0 = Release|Win32 + {5550D94C-D162-4367-BF79-00243E79D3D1}.Release|x64.ActiveCfg = Release|x64 + {5550D94C-D162-4367-BF79-00243E79D3D1}.Release|x64.Build.0 = Release|x64 + {4362D2DF-3F07-4248-9CB4-9682B29EE0D3}.Debug|Win32.ActiveCfg = Debug|Win32 + {4362D2DF-3F07-4248-9CB4-9682B29EE0D3}.Debug|Win32.Build.0 = Debug|Win32 + {4362D2DF-3F07-4248-9CB4-9682B29EE0D3}.Debug|x64.ActiveCfg = Debug|x64 + {4362D2DF-3F07-4248-9CB4-9682B29EE0D3}.Debug|x64.Build.0 = Debug|x64 + {4362D2DF-3F07-4248-9CB4-9682B29EE0D3}.Release|Win32.ActiveCfg = Release|Win32 + {4362D2DF-3F07-4248-9CB4-9682B29EE0D3}.Release|Win32.Build.0 = Release|Win32 + {4362D2DF-3F07-4248-9CB4-9682B29EE0D3}.Release|x64.ActiveCfg = Release|x64 + {4362D2DF-3F07-4248-9CB4-9682B29EE0D3}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1203,6 +1337,24 @@ Global {E0D028F5-7111-465F-B7AB-3E1F60BC29D7} = {44504257-9751-4CA1-AF97-86995FE49C45} {B1F08922-D984-49AD-ADC3-4A77D13A7E1F} = {60A225B4-F05B-412D-82B6-50B9A1539B6A} {7A216D2F-18DC-415A-96E7-A417B1DC7FB4} = {B1F08922-D984-49AD-ADC3-4A77D13A7E1F} + {9F79C5E8-103C-4C38-8CBD-56F80EA85B09} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {E9146C23-516D-4D87-A217-EDF5A08DBF04} = {9F79C5E8-103C-4C38-8CBD-56F80EA85B09} + {D5FFCE1A-7264-42D7-AE3F-60AF35D71B03} = {9F79C5E8-103C-4C38-8CBD-56F80EA85B09} + {FE2D0F22-6A55-427B-BFF2-1B93F166757C} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {0FA27393-6D89-4612-8170-81122C6B8936} = {FE2D0F22-6A55-427B-BFF2-1B93F166757C} + {E7270286-71D1-4C31-A2A4-A9DBA0D28E6C} = {FE2D0F22-6A55-427B-BFF2-1B93F166757C} + {765BF359-660D-4050-9F74-E9BE9212005A} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {7464DBD0-F9B8-4DCE-948E-ED4A12215689} = {765BF359-660D-4050-9F74-E9BE9212005A} + {5362D3A2-6280-4C76-9C98-B2B30F6A7EC6} = {765BF359-660D-4050-9F74-E9BE9212005A} + {C769473B-134B-4FD5-8F37-F22012C08C50} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {639F8A00-F592-4CB3-BC92-0AFB9388D03F} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {07A7881F-0E97-4855-BA2A-8253F30A5FA0} = {C769473B-134B-4FD5-8F37-F22012C08C50} + {558F8E62-C7E5-4DB1-9175-925A0DCE55B7} = {C769473B-134B-4FD5-8F37-F22012C08C50} + {9834D6A0-4696-4525-9BB6-D51AAF557EC1} = {639F8A00-F592-4CB3-BC92-0AFB9388D03F} + {864A92F2-D094-45AF-8277-50F43824C4EE} = {639F8A00-F592-4CB3-BC92-0AFB9388D03F} + {64DF5504-2D9E-409C-A998-0881AB01FC09} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {5550D94C-D162-4367-BF79-00243E79D3D1} = {64DF5504-2D9E-409C-A998-0881AB01FC09} + {4362D2DF-3F07-4248-9CB4-9682B29EE0D3} = {64DF5504-2D9E-409C-A998-0881AB01FC09} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {637833EA-7321-4124-9416-0A38CE37CA31} diff --git a/cpp/DataStorm/clock/Makefile.mk b/cpp/DataStorm/clock/Makefile.mk new file mode 100644 index 000000000..20be945e6 --- /dev/null +++ b/cpp/DataStorm/clock/Makefile.mk @@ -0,0 +1,5 @@ +# Copyright (c) ZeroC, Inc. All rights reserved. + +$(demo)_dependencies = DataStorm Ice + +demos += $(demo) diff --git a/cpp/DataStorm/clock/README.md b/cpp/DataStorm/clock/README.md new file mode 100644 index 000000000..87fb49550 --- /dev/null +++ b/cpp/DataStorm/clock/README.md @@ -0,0 +1,16 @@ +This demo illustrates how to implement a custom encoder and decoder for the topic value type +`chrono::system_clock::time_point`. + +To run the demo, start the writer and specify the name of a city: + +```shell +writer +``` + +In a separate window, start the reader: + +```shell +reader +``` + +The reader will print the time sent by the writer. You can start multiple writers and readers. diff --git a/cpp/DataStorm/clock/Reader.cpp b/cpp/DataStorm/clock/Reader.cpp new file mode 100644 index 000000000..b595b7be2 --- /dev/null +++ b/cpp/DataStorm/clock/Reader.cpp @@ -0,0 +1,86 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#include +#include + +#include +#include + +using namespace std; + +namespace DataStorm +{ + template<> struct Encoder + { + static Ice::ByteSeq encode(const chrono::system_clock::time_point&) + { + assert(false); // Not used by the reader but it still needs to be declared. + return Ice::ByteSeq{}; + } + }; + + template<> struct Decoder + { + static chrono::system_clock::time_point decode(const Ice::ByteSeq& data) + { + // Decode the number of seconds since epoch. The value is encoded in a way which doesn't depend on the + // platform endianess (little endian with variable number of bytes). + long long int value = 0; + for (auto p = data.rbegin(); p != data.rend(); ++p) + { + value = value * 256 + static_cast(*p); + } + return chrono::time_point(chrono::seconds(value)); + } + }; +}; + +int +main(int argc, char* argv[]) +{ + try + { + // CtrlCHandler must be called before the node is created or any other threads are started. + Ice::CtrlCHandler ctrlCHandler; + + // Instantiates node. + DataStorm::Node node(argc, argv, "config.reader"); + + // Shutdown the node on Ctrl-C. + ctrlCHandler.setCallback([&node](int) { node.shutdown(); }); + + // Instantiates the "time" topic. + DataStorm::Topic topic(node, "time"); + + // Instantiate a reader to read the time from all the topic cities. + auto reader = DataStorm::makeAnyKeyReader(topic); + + // Wait for at least on writer to connect. + reader.waitForWriters(); + + // Prints out the received samples. + reader.onSamples( + nullptr, + [](const DataStorm::Sample& sample) + { + auto time = chrono::system_clock::to_time_t(sample.getValue()); + char timeString[100]; + if (strftime(timeString, sizeof(timeString), "%x %X", localtime(&time)) == 0) + { + timeString[0] = '\0'; + } + cout << "received time for `" << sample.getKey() << "': " << timeString << endl; + }); + + // Exit once the user hits Ctrl-C to shutdown the node. + node.waitForShutdown(); + } + catch (const std::exception& ex) + { + cerr << ex.what() << endl; + return 1; + } + return 0; +} diff --git a/cpp/DataStorm/clock/Writer.cpp b/cpp/DataStorm/clock/Writer.cpp new file mode 100644 index 000000000..31a6b7fcb --- /dev/null +++ b/cpp/DataStorm/clock/Writer.cpp @@ -0,0 +1,78 @@ +// Copyright (c) ZeroC, Inc. All rights reserved. + +#include +#include + +#include +#include +#include + +using namespace std; + +namespace DataStorm +{ + template<> struct Encoder + { + static Ice::ByteSeq encode(const chrono::system_clock::time_point& time) + { + // Encode the number of seconds since epoch. The value is encoded in a way which doesn't depend on the + // platform endianess (little endian with variable number of bytes). + Ice::ByteSeq data; + auto value = chrono::time_point_cast(time).time_since_epoch().count(); + while (value) + { + data.push_back(static_cast(value % 256)); + value = value / 256; + } + return data; + } + }; + + template<> struct Decoder + { + static chrono::system_clock::time_point decode(const Ice::ByteSeq&) + { + assert(false); // Not used by the reader but it still needs to be declared. + return chrono::system_clock::time_point(); + } + }; +}; + +int +main(int argc, char* argv[]) +{ + try + { + // CtrlCHandler must be called before the node is created or any other threads are started. + Ice::CtrlCHandler ctrlCHandler; + + // Instantiates node. + DataStorm::Node node(argc, argv, "config.writer"); + + // Shutdown the node on Ctrl-C. + ctrlCHandler.setCallback([&node](int) { node.shutdown(); }); + + // Asks for city name to publish updates + string city; + cout << "Please enter city name: "; + getline(cin, city); + + // Instantiates the "time" topic. + DataStorm::Topic topic(node, "time"); + + // Instantiate a writer to write the time from the given city. + auto writer = DataStorm::makeSingleKeyWriter(topic, city); + + while (!node.isShutdown()) + { + writer.update(chrono::system_clock::now()); + this_thread::sleep_for(chrono::seconds(1)); + } + } + catch (const std::exception& ex) + { + cerr << ex.what() << endl; + return 1; + } + return 0; +} diff --git a/cpp/DataStorm/clock/config.reader b/cpp/DataStorm/clock/config.reader new file mode 100644 index 000000000..4b5b781e4 --- /dev/null +++ b/cpp/DataStorm/clock/config.reader @@ -0,0 +1,26 @@ +# +# Use the localhost interface by default for DataStorm endpoints +# +Ice.Default.Host=localhost + +# +# DataStorm server endpoint +# +#DataStorm.Node.Server.Endpoints=tcp + +# +# DataStorm multicast endpoint +# +#DataStorm.Node.Multicast.Endpoints=udp -h 239.255.0.1 -p 10000 + +# +# DataStorm Tracing +# +#DataStorm.Trace.Topic=1 +#DataStorm.Trace.Data=1 +#DataStorm.Trace.Session=1 + +# +# Ice tracing +# +#Ice.Trace.Network=1 diff --git a/cpp/DataStorm/clock/config.writer b/cpp/DataStorm/clock/config.writer new file mode 100644 index 000000000..4b5b781e4 --- /dev/null +++ b/cpp/DataStorm/clock/config.writer @@ -0,0 +1,26 @@ +# +# Use the localhost interface by default for DataStorm endpoints +# +Ice.Default.Host=localhost + +# +# DataStorm server endpoint +# +#DataStorm.Node.Server.Endpoints=tcp + +# +# DataStorm multicast endpoint +# +#DataStorm.Node.Multicast.Endpoints=udp -h 239.255.0.1 -p 10000 + +# +# DataStorm Tracing +# +#DataStorm.Trace.Topic=1 +#DataStorm.Trace.Data=1 +#DataStorm.Trace.Session=1 + +# +# Ice tracing +# +#Ice.Trace.Network=1 diff --git a/cpp/DataStorm/clock/msbuild/reader/packages.config b/cpp/DataStorm/clock/msbuild/reader/packages.config new file mode 100644 index 000000000..a36cb289a --- /dev/null +++ b/cpp/DataStorm/clock/msbuild/reader/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/clock/msbuild/reader/reader.vcxproj b/cpp/DataStorm/clock/msbuild/reader/reader.vcxproj new file mode 100644 index 000000000..4f1c5c947 --- /dev/null +++ b/cpp/DataStorm/clock/msbuild/reader/reader.vcxproj @@ -0,0 +1,80 @@ + + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + reader + {E9146C23-516D-4D87-A217-EDF5A08DBF04} + + + + Application + $(DefaultPlatformToolset) + true + + + + + ..\..\ + $(Platform)\$(Configuration)\ + + + + $(Platform)\$(Configuration) + 4503 + + + + + $(Platform)\$(Configuration) + 4503 + + + + + $(Platform)\$(Configuration) + 4503 + + + + + $(Platform)\$(Configuration) + 4503 + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/clock/msbuild/reader/reader.vcxproj.filters b/cpp/DataStorm/clock/msbuild/reader/reader.vcxproj.filters new file mode 100644 index 000000000..851de157d --- /dev/null +++ b/cpp/DataStorm/clock/msbuild/reader/reader.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {2f52ec5d-d778-4988-8746-1a2d17b17375} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {d096f6ce-e47c-430a-a7f7-7fe3c2fa047f} + h;hpp;hxx;hm;inl + + + {b3e66749-c970-4413-b670-910ee10bcb50} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {5b1f74bb-bd49-40e8-9d23-bd640b26e7b7} + ice + + + + + Source Files + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/clock/msbuild/reader/reader.vcxproj.user b/cpp/DataStorm/clock/msbuild/reader/reader.vcxproj.user new file mode 100644 index 000000000..af59416bd --- /dev/null +++ b/cpp/DataStorm/clock/msbuild/reader/reader.vcxproj.user @@ -0,0 +1,19 @@ + + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + \ No newline at end of file diff --git a/cpp/DataStorm/clock/msbuild/writer/packages.config b/cpp/DataStorm/clock/msbuild/writer/packages.config new file mode 100644 index 000000000..a36cb289a --- /dev/null +++ b/cpp/DataStorm/clock/msbuild/writer/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/clock/msbuild/writer/writer.vcxproj b/cpp/DataStorm/clock/msbuild/writer/writer.vcxproj new file mode 100644 index 000000000..cce06dc4b --- /dev/null +++ b/cpp/DataStorm/clock/msbuild/writer/writer.vcxproj @@ -0,0 +1,80 @@ + + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + writer + {D5FFCE1A-7264-42D7-AE3F-60AF35D71B03} + + + + Application + $(DefaultPlatformToolset) + true + + + + + ..\..\ + $(Platform)\$(Configuration)\ + + + + $(Platform)\$(Configuration) + 4503 + + + + + $(Platform)\$(Configuration) + 4503 + + + + + $(Platform)\$(Configuration) + 4503 + + + + + $(Platform)\$(Configuration) + 4503 + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/clock/msbuild/writer/writer.vcxproj.filters b/cpp/DataStorm/clock/msbuild/writer/writer.vcxproj.filters new file mode 100644 index 000000000..e16c16ba8 --- /dev/null +++ b/cpp/DataStorm/clock/msbuild/writer/writer.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {2f52ec5d-d778-4988-8746-1a2d17b17375} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {d096f6ce-e47c-430a-a7f7-7fe3c2fa047f} + h;hpp;hxx;hm;inl + + + {b3e66749-c970-4413-b670-910ee10bcb50} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {d8d7456f-5eca-434c-b0c5-0014789f2cd8} + ice + + + + + Source Files + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/clock/msbuild/writer/writer.vcxproj.user b/cpp/DataStorm/clock/msbuild/writer/writer.vcxproj.user new file mode 100644 index 000000000..af59416bd --- /dev/null +++ b/cpp/DataStorm/clock/msbuild/writer/writer.vcxproj.user @@ -0,0 +1,19 @@ + + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + \ No newline at end of file diff --git a/cpp/DataStorm/keyFilter/Makefile.mk b/cpp/DataStorm/keyFilter/Makefile.mk new file mode 100644 index 000000000..20be945e6 --- /dev/null +++ b/cpp/DataStorm/keyFilter/Makefile.mk @@ -0,0 +1,5 @@ +# Copyright (c) ZeroC, Inc. All rights reserved. + +$(demo)_dependencies = DataStorm Ice + +demos += $(demo) diff --git a/cpp/DataStorm/keyFilter/README.md b/cpp/DataStorm/keyFilter/README.md new file mode 100644 index 000000000..2bb521a74 --- /dev/null +++ b/cpp/DataStorm/keyFilter/README.md @@ -0,0 +1,14 @@ +This demo illustrates the use of key filters. The reader uses the `_regex` predefined key filter. The reader will only +subscribe and receive samples for keys matching the regular expression provided on construction of the reader object. + +To run the demo, start the writer: + +```shell +writer +``` + +In a separate window, start the reader: + +```shell +reader +``` diff --git a/cpp/DataStorm/keyFilter/Reader.cpp b/cpp/DataStorm/keyFilter/Reader.cpp new file mode 100644 index 000000000..cb010ad76 --- /dev/null +++ b/cpp/DataStorm/keyFilter/Reader.cpp @@ -0,0 +1,48 @@ +// Copyright (c) ZeroC, Inc. All rights reserved. + +#include +#include + +#include +#include +#include + +using namespace std; + +int +main(int argc, char* argv[]) +{ + try + { + // Instantiates DataStorm node. + DataStorm::Node node(argc, argv, "config.reader"); + + // Instantiates the "hello" topic. The topic uses strings for keys and values. + DataStorm::Topic topic(node, "hello"); + + // Configure readers to never clear the history. We want to receive all the + // samples written by the writers. + topic.setReaderDefaultConfig({std::nullopt, std::nullopt, DataStorm::ClearHistoryPolicy::Never}); + + // + // Instantiate a filtered reader for keys matching the foo[ace] regular expression. + // + auto reader = DataStorm::makeFilteredKeyReader(topic, DataStorm::Filter("_regex", "foo[ace]")); + + // Get the samples published by the writers fooa, fooc and fooe. + auto sample = reader.getNextUnread(); + cout << sample.getKey() << " says " << sample.getValue() << "!" << endl; + + sample = reader.getNextUnread(); + cout << sample.getKey() << " says " << sample.getValue() << "!" << endl; + + sample = reader.getNextUnread(); + cout << sample.getKey() << " says " << sample.getValue() << "!" << endl; + } + catch (const std::exception& ex) + { + cerr << ex.what() << endl; + return 1; + } + return 0; +} diff --git a/cpp/DataStorm/keyFilter/Writer.cpp b/cpp/DataStorm/keyFilter/Writer.cpp new file mode 100644 index 000000000..f785d0aa3 --- /dev/null +++ b/cpp/DataStorm/keyFilter/Writer.cpp @@ -0,0 +1,48 @@ +// Copyright (c) ZeroC, Inc. All rights reserved. + +#include +#include + +#include +#include + +using namespace std; + +int +main(int argc, char* argv[]) +{ + try + { + // Instantiates DataStorm node. + DataStorm::Node node(argc, argv, "config.writer"); + + // Instantiates the "hello" topic. The topic uses strings for keys and values. + DataStorm::Topic topic(node, "hello"); + + // Instantiate writers. + auto writera = DataStorm::makeSingleKeyWriter(topic, "fooa"); + auto writerb = DataStorm::makeSingleKeyWriter(topic, "foob"); + auto writerc = DataStorm::makeSingleKeyWriter(topic, "fooc"); + auto writerd = DataStorm::makeSingleKeyWriter(topic, "food"); + auto writere = DataStorm::makeSingleKeyWriter(topic, "fooe"); + + // Wait for a reader to connect + topic.waitForReaders(); + + // Publish a sample on each writer. + writera.update("hello"); + writerb.update("hello"); + writerc.update("hello"); + writerd.update("hello"); + writere.update("hello"); + + // Wait for readers to disconnect. + topic.waitForNoReaders(); + } + catch (const std::exception& ex) + { + cerr << ex.what() << endl; + return 1; + } + return 0; +} diff --git a/cpp/DataStorm/keyFilter/config.reader b/cpp/DataStorm/keyFilter/config.reader new file mode 100644 index 000000000..4b5b781e4 --- /dev/null +++ b/cpp/DataStorm/keyFilter/config.reader @@ -0,0 +1,26 @@ +# +# Use the localhost interface by default for DataStorm endpoints +# +Ice.Default.Host=localhost + +# +# DataStorm server endpoint +# +#DataStorm.Node.Server.Endpoints=tcp + +# +# DataStorm multicast endpoint +# +#DataStorm.Node.Multicast.Endpoints=udp -h 239.255.0.1 -p 10000 + +# +# DataStorm Tracing +# +#DataStorm.Trace.Topic=1 +#DataStorm.Trace.Data=1 +#DataStorm.Trace.Session=1 + +# +# Ice tracing +# +#Ice.Trace.Network=1 diff --git a/cpp/DataStorm/keyFilter/config.writer b/cpp/DataStorm/keyFilter/config.writer new file mode 100644 index 000000000..4b5b781e4 --- /dev/null +++ b/cpp/DataStorm/keyFilter/config.writer @@ -0,0 +1,26 @@ +# +# Use the localhost interface by default for DataStorm endpoints +# +Ice.Default.Host=localhost + +# +# DataStorm server endpoint +# +#DataStorm.Node.Server.Endpoints=tcp + +# +# DataStorm multicast endpoint +# +#DataStorm.Node.Multicast.Endpoints=udp -h 239.255.0.1 -p 10000 + +# +# DataStorm Tracing +# +#DataStorm.Trace.Topic=1 +#DataStorm.Trace.Data=1 +#DataStorm.Trace.Session=1 + +# +# Ice tracing +# +#Ice.Trace.Network=1 diff --git a/cpp/DataStorm/keyFilter/msbuild/reader/packages.config b/cpp/DataStorm/keyFilter/msbuild/reader/packages.config new file mode 100644 index 000000000..a36cb289a --- /dev/null +++ b/cpp/DataStorm/keyFilter/msbuild/reader/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/keyFilter/msbuild/reader/reader.vcxproj b/cpp/DataStorm/keyFilter/msbuild/reader/reader.vcxproj new file mode 100644 index 000000000..bd1fd26dc --- /dev/null +++ b/cpp/DataStorm/keyFilter/msbuild/reader/reader.vcxproj @@ -0,0 +1,76 @@ + + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + reader + {0FA27393-6D89-4612-8170-81122C6B8936} + + + + Application + $(DefaultPlatformToolset) + true + + + + + ..\..\ + $(Platform)\$(Configuration)\ + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/keyFilter/msbuild/reader/reader.vcxproj.filters b/cpp/DataStorm/keyFilter/msbuild/reader/reader.vcxproj.filters new file mode 100644 index 000000000..cf84c63a8 --- /dev/null +++ b/cpp/DataStorm/keyFilter/msbuild/reader/reader.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {2f52ec5d-d778-4988-8746-1a2d17b17375} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {d096f6ce-e47c-430a-a7f7-7fe3c2fa047f} + h;hpp;hxx;hm;inl + + + {b3e66749-c970-4413-b670-910ee10bcb50} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {c84cdc06-8bc8-4b27-8e96-205a0f2d505c} + ice + + + + + Source Files + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/keyFilter/msbuild/reader/reader.vcxproj.user b/cpp/DataStorm/keyFilter/msbuild/reader/reader.vcxproj.user new file mode 100644 index 000000000..af59416bd --- /dev/null +++ b/cpp/DataStorm/keyFilter/msbuild/reader/reader.vcxproj.user @@ -0,0 +1,19 @@ + + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + \ No newline at end of file diff --git a/cpp/DataStorm/keyFilter/msbuild/writer/packages.config b/cpp/DataStorm/keyFilter/msbuild/writer/packages.config new file mode 100644 index 000000000..26eaca345 --- /dev/null +++ b/cpp/DataStorm/keyFilter/msbuild/writer/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/keyFilter/msbuild/writer/writer.vcxproj b/cpp/DataStorm/keyFilter/msbuild/writer/writer.vcxproj new file mode 100644 index 000000000..acf8fa8e6 --- /dev/null +++ b/cpp/DataStorm/keyFilter/msbuild/writer/writer.vcxproj @@ -0,0 +1,76 @@ + + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + writer + {E7270286-71D1-4C31-A2A4-A9DBA0D28E6C} + + + + Application + $(DefaultPlatformToolset) + true + + + + + ..\..\ + $(Platform)\$(Configuration)\ + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/keyFilter/msbuild/writer/writer.vcxproj.filters b/cpp/DataStorm/keyFilter/msbuild/writer/writer.vcxproj.filters new file mode 100644 index 000000000..8ce8a5b76 --- /dev/null +++ b/cpp/DataStorm/keyFilter/msbuild/writer/writer.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {2f52ec5d-d778-4988-8746-1a2d17b17375} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {d096f6ce-e47c-430a-a7f7-7fe3c2fa047f} + h;hpp;hxx;hm;inl + + + {b3e66749-c970-4413-b670-910ee10bcb50} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {c9c0d8fc-2e6f-4b36-b0ac-aaae0e780a6e} + ice + + + + + Source Files + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/keyFilter/msbuild/writer/writer.vcxproj.user b/cpp/DataStorm/keyFilter/msbuild/writer/writer.vcxproj.user new file mode 100644 index 000000000..af59416bd --- /dev/null +++ b/cpp/DataStorm/keyFilter/msbuild/writer/writer.vcxproj.user @@ -0,0 +1,19 @@ + + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + \ No newline at end of file diff --git a/cpp/DataStorm/minimal/Makefile.mk b/cpp/DataStorm/minimal/Makefile.mk new file mode 100644 index 000000000..20be945e6 --- /dev/null +++ b/cpp/DataStorm/minimal/Makefile.mk @@ -0,0 +1,5 @@ +# Copyright (c) ZeroC, Inc. All rights reserved. + +$(demo)_dependencies = DataStorm Ice + +demos += $(demo) diff --git a/cpp/DataStorm/minimal/README.md b/cpp/DataStorm/minimal/README.md new file mode 100644 index 000000000..4d56f6170 --- /dev/null +++ b/cpp/DataStorm/minimal/README.md @@ -0,0 +1,13 @@ +This demo is the minimal DataStorm "hello world" application. + +To run the demo, start the writer: + +```shell +writer +``` + +In a separate window, start the reader: + +```shell +reader +``` diff --git a/cpp/DataStorm/minimal/Reader.cpp b/cpp/DataStorm/minimal/Reader.cpp new file mode 100644 index 000000000..c86f56fd2 --- /dev/null +++ b/cpp/DataStorm/minimal/Reader.cpp @@ -0,0 +1,35 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +#include + +#include + +using namespace std; + +int +main(int argc, char* argv[]) +{ + try + { + // Instantiates DataStorm node. + DataStorm::Node node(argc, argv); + + // Instantiates the "hello" topic. The topic uses strings for keys and values. + DataStorm::Topic topic(node, "hello"); + + // Instantiate a reader with the key "foo". + auto reader = DataStorm::makeSingleKeyReader(topic, "foo"); + + // Get sample. + auto sample = reader.getNextUnread(); + cout << sample.getKey() << " says " << sample.getValue() << "!" << endl; + } + catch (const std::exception& ex) + { + cerr << ex.what() << endl; + return 1; + } + return 0; +} diff --git a/cpp/DataStorm/minimal/Writer.cpp b/cpp/DataStorm/minimal/Writer.cpp new file mode 100644 index 000000000..f876f142b --- /dev/null +++ b/cpp/DataStorm/minimal/Writer.cpp @@ -0,0 +1,36 @@ +// Copyright (c) ZeroC, Inc. All rights reserved. + +#include + +#include + +using namespace std; + +int +main(int argc, char* argv[]) +{ + try + { + // Instantiates DataStorm node. + DataStorm::Node node(argc, argv); + + // Instantiates the "hello" topic. The topic uses strings for keys and values. + DataStorm::Topic topic(node, "hello"); + + // Instantiate a writer with the key "foo" and wait for a reader to connect. + auto writer = DataStorm::makeSingleKeyWriter(topic, "foo"); + writer.waitForReaders(); + + // Publish a sample. + writer.update("hello"); + + // Wait for the reader to disconnect. + writer.waitForNoReaders(); + } + catch (const std::exception& ex) + { + cerr << ex.what() << endl; + return 1; + } + return 0; +} diff --git a/cpp/DataStorm/minimal/msbuild/reader/packages.config b/cpp/DataStorm/minimal/msbuild/reader/packages.config new file mode 100644 index 000000000..a36cb289a --- /dev/null +++ b/cpp/DataStorm/minimal/msbuild/reader/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/minimal/msbuild/reader/reader.vcxproj b/cpp/DataStorm/minimal/msbuild/reader/reader.vcxproj new file mode 100644 index 000000000..5631e08c9 --- /dev/null +++ b/cpp/DataStorm/minimal/msbuild/reader/reader.vcxproj @@ -0,0 +1,76 @@ + + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + reader + {7464DBD0-F9B8-4DCE-948E-ED4A12215689} + + + + Application + $(DefaultPlatformToolset) + true + + + + + ..\..\ + $(Platform)\$(Configuration)\ + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/minimal/msbuild/reader/reader.vcxproj.filters b/cpp/DataStorm/minimal/msbuild/reader/reader.vcxproj.filters new file mode 100644 index 000000000..d77db7486 --- /dev/null +++ b/cpp/DataStorm/minimal/msbuild/reader/reader.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {2f52ec5d-d778-4988-8746-1a2d17b17375} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {d096f6ce-e47c-430a-a7f7-7fe3c2fa047f} + h;hpp;hxx;hm;inl + + + {b3e66749-c970-4413-b670-910ee10bcb50} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {416dec91-d340-4fe7-be6e-bb145f8a1869} + ice + + + + + Source Files + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/minimal/msbuild/reader/reader.vcxproj.user b/cpp/DataStorm/minimal/msbuild/reader/reader.vcxproj.user new file mode 100644 index 000000000..88a550947 --- /dev/null +++ b/cpp/DataStorm/minimal/msbuild/reader/reader.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/cpp/DataStorm/minimal/msbuild/writer/packages.config b/cpp/DataStorm/minimal/msbuild/writer/packages.config new file mode 100644 index 000000000..a36cb289a --- /dev/null +++ b/cpp/DataStorm/minimal/msbuild/writer/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/minimal/msbuild/writer/writer.vcxproj b/cpp/DataStorm/minimal/msbuild/writer/writer.vcxproj new file mode 100644 index 000000000..f3442022a --- /dev/null +++ b/cpp/DataStorm/minimal/msbuild/writer/writer.vcxproj @@ -0,0 +1,76 @@ + + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + writer + {5362D3A2-6280-4C76-9C98-B2B30F6A7EC6} + + + + Application + $(DefaultPlatformToolset) + true + + + + + ..\..\ + $(Platform)\$(Configuration)\ + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/minimal/msbuild/writer/writer.vcxproj.filters b/cpp/DataStorm/minimal/msbuild/writer/writer.vcxproj.filters new file mode 100644 index 000000000..f97b40e54 --- /dev/null +++ b/cpp/DataStorm/minimal/msbuild/writer/writer.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {2f52ec5d-d778-4988-8746-1a2d17b17375} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {d096f6ce-e47c-430a-a7f7-7fe3c2fa047f} + h;hpp;hxx;hm;inl + + + {b3e66749-c970-4413-b670-910ee10bcb50} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {dd1ed1b5-14c9-474a-ab38-9b5b05f2a2e2} + ice + + + + + Source Files + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/minimal/msbuild/writer/writer.vcxproj.user b/cpp/DataStorm/minimal/msbuild/writer/writer.vcxproj.user new file mode 100644 index 000000000..88a550947 --- /dev/null +++ b/cpp/DataStorm/minimal/msbuild/writer/writer.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/cpp/DataStorm/node/Makefile.mk b/cpp/DataStorm/node/Makefile.mk new file mode 100644 index 000000000..20be945e6 --- /dev/null +++ b/cpp/DataStorm/node/Makefile.mk @@ -0,0 +1,5 @@ +# Copyright (c) ZeroC, Inc. All rights reserved. + +$(demo)_dependencies = DataStorm Ice + +demos += $(demo) diff --git a/cpp/DataStorm/node/README.md b/cpp/DataStorm/node/README.md new file mode 100644 index 000000000..1b6c36a5c --- /dev/null +++ b/cpp/DataStorm/node/README.md @@ -0,0 +1,33 @@ +This demo illustrates the use of a DataStorm node to discover writers and readers without using UDP multicast. + +It also demonstrates how readers and writers can exchange data through the DataStorm node when the server endpoints +of both the writers and readers are disabled. + +To run the demo, start a DataStorm node: + +```shell +dsnode --Ice.Config=config.node +``` + +In a separate window, start the writer: + +```shell +writer +``` + +In a separate window, start the reader: + +```shell +reader +``` + +You can start multiple readers and writers. The readers print the time sent by the writers. Stopping the DataStorm node +prevents communications between readers and writers and the discovery of new readers and writers. Restarting the node +resumes data exchange and discovery. + +You can enable the reader or the writer's server endpoints by editing the `config.writer` or `config.reader` file. When +server endpoints are enabled (either for the reader or the writer), a direct connection is established between the +reader and the writer during the discovery process. The connection is from the reader or writer without server endpoints +to the reader or writer with server endpoints. Stopping the DataStorm node at this point does not impede communications +between readers and writers (since they are directly connected to one another); it does however prevent discovery of new +readers and writers. diff --git a/cpp/DataStorm/node/Reader.cpp b/cpp/DataStorm/node/Reader.cpp new file mode 100644 index 000000000..04be5fc30 --- /dev/null +++ b/cpp/DataStorm/node/Reader.cpp @@ -0,0 +1,45 @@ +// Copyright (c) ZeroC, Inc. All rights reserved. + +#include +#include + +#include + +using namespace std; + +int +main(int argc, char* argv[]) +{ + try + { + // CtrlCHandler must be called before the node is created or any other threads are started. + Ice::CtrlCHandler ctrlCHandler; + + // Instantiates node. + DataStorm::Node node(argc, argv, "config.reader"); + + // Shutdown the node on Ctrl-C. + ctrlCHandler.setCallback([&node](int) { node.shutdown(); }); + + // Instantiates the "time" topic. + DataStorm::Topic topic(node, "time"); + + // Instantiate a reader to read the time from all the topic writers. + auto reader = DataStorm::makeAnyKeyReader(topic); + + // Prints out the received samples. + reader.onSamples( + nullptr, + [](const DataStorm::Sample& sample) + { cout << "[" << sample.getKey() << "] received time: " << sample.getValue() << endl; }); + + // Exit once the user hits Ctrl-C to shutdown the node. + node.waitForShutdown(); + } + catch (const std::exception& ex) + { + cerr << ex.what() << endl; + return 1; + } + return 0; +} diff --git a/cpp/DataStorm/node/Writer.cpp b/cpp/DataStorm/node/Writer.cpp new file mode 100644 index 000000000..b6928511b --- /dev/null +++ b/cpp/DataStorm/node/Writer.cpp @@ -0,0 +1,57 @@ +// Copyright (c) ZeroC, Inc. All rights reserved. + +#include +#include + +#include +#include +#include +#include + +using namespace std; + +int +main(int argc, char* argv[]) +{ + try + { + // CtrlCHandler must be called before the node is created or any other threads are started. + Ice::CtrlCHandler ctrlCHandler; + + // Setup a random generator to generate an identifier for the writer. + random_device rd; + mt19937 generator(rd()); + uniform_int_distribution<> id(1); + + // Instantiates node. + DataStorm::Node node(argc, argv, "config.writer"); + + // Shutdown the node on Ctrl-C. + ctrlCHandler.setCallback([&node](int) { node.shutdown(); }); + + // Instantiates the "time" topic. + DataStorm::Topic topic(node, "time"); + + // Instantiate a writer to write the local time. The writer key is a random + // integer value that identifies the writer. + auto writer = DataStorm::makeSingleKeyWriter(topic, id(generator)); + + while (!node.isShutdown()) + { + auto now = chrono::system_clock::to_time_t(chrono::system_clock::now()); + char timeString[100]; + if (strftime(timeString, sizeof(timeString), "%x %X", localtime(&now)) == 0) + { + timeString[0] = '\0'; + } + writer.update(timeString); + this_thread::sleep_for(chrono::seconds(1)); + } + } + catch (const std::exception& ex) + { + cerr << ex.what() << endl; + return 1; + } + return 0; +} diff --git a/cpp/DataStorm/node/config.node b/cpp/DataStorm/node/config.node new file mode 100644 index 000000000..dd39f959b --- /dev/null +++ b/cpp/DataStorm/node/config.node @@ -0,0 +1,26 @@ +# +# Use the localhost interface by default for DataStorm endpoints +# +Ice.Default.Host=localhost + +# +# Disable the multicast endpoint +# +#DataStorm.Node.Multicast.Enabled=0 + +# +# Listen on the TCP endpoint with port 10000 +# +DataStorm.Node.Server.Endpoints=tcp -p 10000 + +# +# DataStorm Tracing +# +#DataStorm.Trace.Topic=1 +#DataStorm.Trace.Data=1 +#DataStorm.Trace.Session=1 + +# +# Ice tracing +# +#Ice.Trace.Network=1 diff --git a/cpp/DataStorm/node/config.reader b/cpp/DataStorm/node/config.reader new file mode 100644 index 000000000..479c6f91b --- /dev/null +++ b/cpp/DataStorm/node/config.reader @@ -0,0 +1,38 @@ +# +# Use the localhost interface by default for DataStorm endpoints +# +Ice.Default.Host=localhost + +# +# Connect to the DataStorm node running on port 10000 +# +DataStorm.Node.ConnectTo=tcp -p 10000 + +# +# Disable the multicast endpoint +# +DataStorm.Node.Multicast.Enabled=0 + +# +# Disable the server endpoints. The reader won't accept any connections +# from writers. If the writer accepts connections, the reader will +# establish a connection to the writer to exchange data. Otherwise, +# it will exchange data through the connection established with the +# DataStorm node. +# +# You can comment out this property to allow readers to connect to the +# writer directly. +# +DataStorm.Node.Server.Enabled=0 + +# +# DataStorm Tracing +# +#DataStorm.Trace.Topic=1 +#DataStorm.Trace.Data=1 +#DataStorm.Trace.Session=1 + +# +# Ice tracing +# +#Ice.Trace.Network=1 diff --git a/cpp/DataStorm/node/config.writer b/cpp/DataStorm/node/config.writer new file mode 100644 index 000000000..ed087566a --- /dev/null +++ b/cpp/DataStorm/node/config.writer @@ -0,0 +1,38 @@ +# +# Use the localhost interface by default for DataStorm endpoints +# +Ice.Default.Host=localhost + +# +# Connect to the DataStorm node running on port 10000 +# +DataStorm.Node.ConnectTo=tcp -p 10000 + +# +# Disable the multicast endpoint +# +DataStorm.Node.Multicast.Enabled=0 + +# +# Disable the server endpoints. The writer won't accept any connections +# from readers. If the reader accepts connections, the writer will +# establish a connection to the reader to exchange data. Otherwise, +# it will exchange data through the connection established with the +# DataStorm node. +# +# You can comment out this property to allow readers to connect to the +# writer directly. +# +DataStorm.Node.Server.Enabled=0 + +# +# DataStorm Tracing +# +#DataStorm.Trace.Topic=1 +#DataStorm.Trace.Data=1 +#DataStorm.Trace.Session=1 + +# +# Ice tracing +# +#Ice.Trace.Network=1 diff --git a/cpp/DataStorm/node/msbuild/reader/packages.config b/cpp/DataStorm/node/msbuild/reader/packages.config new file mode 100644 index 000000000..a36cb289a --- /dev/null +++ b/cpp/DataStorm/node/msbuild/reader/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/node/msbuild/reader/reader.vcxproj b/cpp/DataStorm/node/msbuild/reader/reader.vcxproj new file mode 100644 index 000000000..1beeae51d --- /dev/null +++ b/cpp/DataStorm/node/msbuild/reader/reader.vcxproj @@ -0,0 +1,80 @@ + + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + reader + {07A7881F-0E97-4855-BA2A-8253F30A5FA0} + + + + Application + $(DefaultPlatformToolset) + true + + + + + ..\..\ + $(Platform)\$(Configuration)\ + + + + $(Platform)\$(Configuration) + 4503 + + + + + $(Platform)\$(Configuration) + 4503 + + + + + $(Platform)\$(Configuration) + 4503 + + + + + $(Platform)\$(Configuration) + 4503 + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + diff --git a/cpp/DataStorm/node/msbuild/reader/reader.vcxproj.filters b/cpp/DataStorm/node/msbuild/reader/reader.vcxproj.filters new file mode 100644 index 000000000..851de157d --- /dev/null +++ b/cpp/DataStorm/node/msbuild/reader/reader.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {2f52ec5d-d778-4988-8746-1a2d17b17375} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {d096f6ce-e47c-430a-a7f7-7fe3c2fa047f} + h;hpp;hxx;hm;inl + + + {b3e66749-c970-4413-b670-910ee10bcb50} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {5b1f74bb-bd49-40e8-9d23-bd640b26e7b7} + ice + + + + + Source Files + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/node/msbuild/reader/reader.vcxproj.user b/cpp/DataStorm/node/msbuild/reader/reader.vcxproj.user new file mode 100644 index 000000000..af59416bd --- /dev/null +++ b/cpp/DataStorm/node/msbuild/reader/reader.vcxproj.user @@ -0,0 +1,19 @@ + + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + \ No newline at end of file diff --git a/cpp/DataStorm/node/msbuild/writer/packages.config b/cpp/DataStorm/node/msbuild/writer/packages.config new file mode 100644 index 000000000..a36cb289a --- /dev/null +++ b/cpp/DataStorm/node/msbuild/writer/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/node/msbuild/writer/writer.vcxproj b/cpp/DataStorm/node/msbuild/writer/writer.vcxproj new file mode 100644 index 000000000..c035b4109 --- /dev/null +++ b/cpp/DataStorm/node/msbuild/writer/writer.vcxproj @@ -0,0 +1,80 @@ + + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + writer + {558F8E62-C7E5-4DB1-9175-925A0DCE55B7} + + + + Application + $(DefaultPlatformToolset) + true + + + + + ..\..\ + $(Platform)\$(Configuration)\ + + + + $(Platform)\$(Configuration) + 4503 + + + + + $(Platform)\$(Configuration) + 4503 + + + + + $(Platform)\$(Configuration) + 4503 + + + + + $(Platform)\$(Configuration) + 4503 + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + diff --git a/cpp/DataStorm/node/msbuild/writer/writer.vcxproj.filters b/cpp/DataStorm/node/msbuild/writer/writer.vcxproj.filters new file mode 100644 index 000000000..e16c16ba8 --- /dev/null +++ b/cpp/DataStorm/node/msbuild/writer/writer.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {2f52ec5d-d778-4988-8746-1a2d17b17375} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {d096f6ce-e47c-430a-a7f7-7fe3c2fa047f} + h;hpp;hxx;hm;inl + + + {b3e66749-c970-4413-b670-910ee10bcb50} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {d8d7456f-5eca-434c-b0c5-0014789f2cd8} + ice + + + + + Source Files + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/node/msbuild/writer/writer.vcxproj.user b/cpp/DataStorm/node/msbuild/writer/writer.vcxproj.user new file mode 100644 index 000000000..af59416bd --- /dev/null +++ b/cpp/DataStorm/node/msbuild/writer/writer.vcxproj.user @@ -0,0 +1,19 @@ + + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + \ No newline at end of file diff --git a/cpp/DataStorm/sampleFilter/Makefile.mk b/cpp/DataStorm/sampleFilter/Makefile.mk new file mode 100644 index 000000000..20be945e6 --- /dev/null +++ b/cpp/DataStorm/sampleFilter/Makefile.mk @@ -0,0 +1,5 @@ +# Copyright (c) ZeroC, Inc. All rights reserved. + +$(demo)_dependencies = DataStorm Ice + +demos += $(demo) diff --git a/cpp/DataStorm/sampleFilter/README.md b/cpp/DataStorm/sampleFilter/README.md new file mode 100644 index 000000000..3c0adc07c --- /dev/null +++ b/cpp/DataStorm/sampleFilter/README.md @@ -0,0 +1,15 @@ +This demo illustrates the use of sample filters. The reader uses the `_regex` predefined sample filter. The reader will +only receive samples matching the regular expression provided on construction of the reader object. Note that the +filtering of the samples is performed on the writer to minimize the number of events sent over the wire. + +To run the demo, start the writer: + +```shell +writer +``` + +In a separate window, start the reader: + +```shell +reader +``` diff --git a/cpp/DataStorm/sampleFilter/Reader.cpp b/cpp/DataStorm/sampleFilter/Reader.cpp new file mode 100644 index 000000000..c4bbd1a19 --- /dev/null +++ b/cpp/DataStorm/sampleFilter/Reader.cpp @@ -0,0 +1,43 @@ +// Copyright (c) ZeroC, Inc. All rights reserved. + +#include +#include + +#include +#include +#include + +using namespace std; + +int +main(int argc, char* argv[]) +{ + try + { + // Instantiates DataStorm node. + DataStorm::Node node(argc, argv, "config.reader"); + + // Instantiates the "hello" topic. The topic uses strings for keys and values. + DataStorm::Topic topic(node, "hello"); + + // Configure readers to never clear the history. We want to receive all the samples written by the writers. + topic.setReaderDefaultConfig({std::nullopt, std::nullopt, DataStorm::ClearHistoryPolicy::Never}); + + // Instantiate the reader for the key "foo". The reader uses the predefined _regex sample filter and the + // "good.*" regular expression as the criteria. + auto reader = DataStorm::makeSingleKeyReader(topic, "foo", DataStorm::Filter("_regex", "good.*")); + + // Get the 2 samples starting with good published by the writer. + auto sample = reader.getNextUnread(); + cout << sample.getKey() << " says " << sample.getValue() << "!" << endl; + + sample = reader.getNextUnread(); + cout << sample.getKey() << " says " << sample.getValue() << "!" << endl; + } + catch (const std::exception& ex) + { + cerr << ex.what() << endl; + return 1; + } + return 0; +} diff --git a/cpp/DataStorm/sampleFilter/Writer.cpp b/cpp/DataStorm/sampleFilter/Writer.cpp new file mode 100644 index 000000000..d80b29a84 --- /dev/null +++ b/cpp/DataStorm/sampleFilter/Writer.cpp @@ -0,0 +1,46 @@ +// Copyright (c) ZeroC, Inc. All rights reserved. + +#include +#include + +#include +#include +#include + +using namespace std; + +int +main(int argc, char* argv[]) +{ + try + { + // Instantiates DataStorm node. + DataStorm::Node node(argc, argv, "config.writer"); + + // Instantiates the "hello" topic. The topic uses strings for keys and values. + DataStorm::Topic topic(node, "hello"); + + // Configure writers to not clear the history. We want the readers to receive all the writer samples. + topic.setWriterDefaultConfig({std::nullopt, std::nullopt, DataStorm::ClearHistoryPolicy::Never}); + + // Instantiate the foo writer and wait for a reader to connect. + auto writer = DataStorm::makeSingleKeyWriter(topic, "foo"); + topic.waitForReaders(); + + // Publish samples + writer.update("hi"); + writer.update("greetings"); + writer.update("good morning"); + writer.update("hello"); + writer.update("good afternoon"); + + // Wait for readers to disconnect. + topic.waitForNoReaders(); + } + catch (const std::exception& ex) + { + cerr << ex.what() << endl; + return 1; + } + return 0; +} diff --git a/cpp/DataStorm/sampleFilter/config.reader b/cpp/DataStorm/sampleFilter/config.reader new file mode 100644 index 000000000..4b5b781e4 --- /dev/null +++ b/cpp/DataStorm/sampleFilter/config.reader @@ -0,0 +1,26 @@ +# +# Use the localhost interface by default for DataStorm endpoints +# +Ice.Default.Host=localhost + +# +# DataStorm server endpoint +# +#DataStorm.Node.Server.Endpoints=tcp + +# +# DataStorm multicast endpoint +# +#DataStorm.Node.Multicast.Endpoints=udp -h 239.255.0.1 -p 10000 + +# +# DataStorm Tracing +# +#DataStorm.Trace.Topic=1 +#DataStorm.Trace.Data=1 +#DataStorm.Trace.Session=1 + +# +# Ice tracing +# +#Ice.Trace.Network=1 diff --git a/cpp/DataStorm/sampleFilter/config.writer b/cpp/DataStorm/sampleFilter/config.writer new file mode 100644 index 000000000..4b5b781e4 --- /dev/null +++ b/cpp/DataStorm/sampleFilter/config.writer @@ -0,0 +1,26 @@ +# +# Use the localhost interface by default for DataStorm endpoints +# +Ice.Default.Host=localhost + +# +# DataStorm server endpoint +# +#DataStorm.Node.Server.Endpoints=tcp + +# +# DataStorm multicast endpoint +# +#DataStorm.Node.Multicast.Endpoints=udp -h 239.255.0.1 -p 10000 + +# +# DataStorm Tracing +# +#DataStorm.Trace.Topic=1 +#DataStorm.Trace.Data=1 +#DataStorm.Trace.Session=1 + +# +# Ice tracing +# +#Ice.Trace.Network=1 diff --git a/cpp/DataStorm/sampleFilter/msbuild/reader/packages.config b/cpp/DataStorm/sampleFilter/msbuild/reader/packages.config new file mode 100644 index 000000000..a36cb289a --- /dev/null +++ b/cpp/DataStorm/sampleFilter/msbuild/reader/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/sampleFilter/msbuild/reader/reader.vcxproj b/cpp/DataStorm/sampleFilter/msbuild/reader/reader.vcxproj new file mode 100644 index 000000000..cb0b50e84 --- /dev/null +++ b/cpp/DataStorm/sampleFilter/msbuild/reader/reader.vcxproj @@ -0,0 +1,76 @@ + + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + reader + {9834D6A0-4696-4525-9BB6-D51AAF557EC1} + + + + Application + $(DefaultPlatformToolset) + true + + + + + ..\..\ + $(Platform)\$(Configuration)\ + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/sampleFilter/msbuild/reader/reader.vcxproj.filters b/cpp/DataStorm/sampleFilter/msbuild/reader/reader.vcxproj.filters new file mode 100644 index 000000000..2f2d3625e --- /dev/null +++ b/cpp/DataStorm/sampleFilter/msbuild/reader/reader.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {2f52ec5d-d778-4988-8746-1a2d17b17375} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {d096f6ce-e47c-430a-a7f7-7fe3c2fa047f} + h;hpp;hxx;hm;inl + + + {b3e66749-c970-4413-b670-910ee10bcb50} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {44b6d4de-253a-43e2-9156-f233514950f8} + ice + + + + + Source Files + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/sampleFilter/msbuild/reader/reader.vcxproj.user b/cpp/DataStorm/sampleFilter/msbuild/reader/reader.vcxproj.user new file mode 100644 index 000000000..af59416bd --- /dev/null +++ b/cpp/DataStorm/sampleFilter/msbuild/reader/reader.vcxproj.user @@ -0,0 +1,19 @@ + + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + \ No newline at end of file diff --git a/cpp/DataStorm/sampleFilter/msbuild/writer/packages.config b/cpp/DataStorm/sampleFilter/msbuild/writer/packages.config new file mode 100644 index 000000000..a36cb289a --- /dev/null +++ b/cpp/DataStorm/sampleFilter/msbuild/writer/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/sampleFilter/msbuild/writer/writer.vcxproj b/cpp/DataStorm/sampleFilter/msbuild/writer/writer.vcxproj new file mode 100644 index 000000000..d8584d1b1 --- /dev/null +++ b/cpp/DataStorm/sampleFilter/msbuild/writer/writer.vcxproj @@ -0,0 +1,76 @@ + + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + writer + {864A92F2-D094-45AF-8277-50F43824C4EE} + + + + Application + $(DefaultPlatformToolset) + true + + + + + ..\..\ + $(Platform)\$(Configuration)\ + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/sampleFilter/msbuild/writer/writer.vcxproj.filters b/cpp/DataStorm/sampleFilter/msbuild/writer/writer.vcxproj.filters new file mode 100644 index 000000000..2db4ff040 --- /dev/null +++ b/cpp/DataStorm/sampleFilter/msbuild/writer/writer.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {2f52ec5d-d778-4988-8746-1a2d17b17375} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {d096f6ce-e47c-430a-a7f7-7fe3c2fa047f} + h;hpp;hxx;hm;inl + + + {b3e66749-c970-4413-b670-910ee10bcb50} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {53c9fd79-4249-4a4c-8fce-b70151ba8692} + ice + + + + + Source Files + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/sampleFilter/msbuild/writer/writer.vcxproj.user b/cpp/DataStorm/sampleFilter/msbuild/writer/writer.vcxproj.user new file mode 100644 index 000000000..af59416bd --- /dev/null +++ b/cpp/DataStorm/sampleFilter/msbuild/writer/writer.vcxproj.user @@ -0,0 +1,19 @@ + + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + \ No newline at end of file diff --git a/cpp/DataStorm/stock/Makefile.mk b/cpp/DataStorm/stock/Makefile.mk new file mode 100644 index 000000000..20be945e6 --- /dev/null +++ b/cpp/DataStorm/stock/Makefile.mk @@ -0,0 +1,5 @@ +# Copyright (c) ZeroC, Inc. All rights reserved. + +$(demo)_dependencies = DataStorm Ice + +demos += $(demo) diff --git a/cpp/DataStorm/stock/README.md b/cpp/DataStorm/stock/README.md new file mode 100644 index 000000000..1e06c6310 --- /dev/null +++ b/cpp/DataStorm/stock/README.md @@ -0,0 +1,21 @@ +This demo illustrates the use of partial updates. The writer adds stocks to the +topic and send partial updates to update the stock price or volume. The reader +prints out the stock information and partial updates. + +The demo uses Slice to define the `Demo::Stock` class in the `Stock.ice` file. + +To run the demo, start the writer and specify the ticker of the stocks to write: + +``` +writer +``` + +In a separate window, start the reader and specify the stock tickers you wish to +follow: + +``` +reader +``` + +You can start multiple writers and readers to publish or follow different +stocks. diff --git a/cpp/DataStorm/stock/Reader.cpp b/cpp/DataStorm/stock/Reader.cpp new file mode 100644 index 000000000..b3776a002 --- /dev/null +++ b/cpp/DataStorm/stock/Reader.cpp @@ -0,0 +1,139 @@ +// Copyright (c) ZeroC, Inc. All rights reserved. + +#include +#include + +#include "Stock.h" + +#include + +using namespace std; +using namespace Demo; + +int +main(int argc, char* argv[]) +{ + try + { + // CtrlCHandler must be called before the node is created or any other threads are started. + Ice::CtrlCHandler ctrlCHandler; + + // Instantiates node. + DataStorm::Node node(argc, argv, "config.reader"); + + // Shutdown the node on Ctrl-C. + ctrlCHandler.setCallback([&node](int) { node.shutdown(); }); + + // Instantiates the "stocks" topic. + DataStorm::Topic topic(node, "stocks"); + + // Setup partial update updaters. The updater is responsible for updating the element value when a partial + // update is received. Updaters must be set on the topic from both the reader and writer. + topic.setUpdater("price", [](Stock& stock, float price) { stock.price = price; }); + topic.setUpdater("volume", [](Stock& stock, int volume) { stock.volume = volume; }); + + shared_ptr::ReaderType> reader; + { + // Create a reader that connects to all the keys but doesn't receive any samples (we use the `_event' + // predefined sample filter with an empty set of sample events to discard events on the writer). + auto stocks = DataStorm::makeAnyKeyReader( + topic, + DataStorm::Filter("_event", DataStorm::SampleEventSeq{})); + stocks.waitForWriters(); + + // Get the set of stocks connected with the any reader and display their ticker. + std::promise p; + stocks.onConnectedKeys( + [&p](vector tickers) + { + cout << "Available stock(s): " << endl; + for (auto ticker : tickers) + { + cout << ticker << endl; + } + p.set_value(); + }, + [](DataStorm::CallbackReason action, string ticker) + { + if (action == DataStorm::CallbackReason::Connect) + { + cout << "New stock available: " << ticker << endl; + } + else + { + cout << "Stock no longer available: " << ticker << endl; + } + }); + p.get_future().get(); + + string stock; + cout << "Please enter the stock to follow (default = all):\n"; + getline(cin, stock); + + // Read values for the given stock using a key reader. + if (stock.empty() || stock == "all") + { + reader = make_shared>(topic, vector{}); + } + else + { + auto tickers = stocks.getConnectedKeys(); + if (find(tickers.begin(), tickers.end(), stock) == tickers.end()) + { + cout << "unknown stock `" << stock << "'" << endl; + return 1; + } + reader = make_shared>(topic, stock); + } + } + + // Wait for the writer to be connected. + reader->waitForWriters(); + + auto displaySample = [](DataStorm::Sample s) + { + if (s.getEvent() == DataStorm::SampleEvent::Add || s.getEvent() == DataStorm::SampleEvent::Update) + { + auto value = s.getValue(); + cout << "Stock: " << value.name << " (" << s.getKey() << ")" << endl; + cout << "Price: " << value.price << endl; + cout << "Best bid/ask: " << value.bestBid << '/' << value.bestAsk << endl; + cout << "Market Cap: " << value.marketCap << endl; + cout << "Previous close: " << value.previousClose << endl; + cout << "Volume: " << value.volume << endl; + cout << endl; + } + else if (s.getEvent() == DataStorm::SampleEvent::PartialUpdate) + { + if (s.getUpdateTag() == "price") + { + cout << "received price update for " << s.getKey() << ": " << s.getValue().price << endl; + } + else if (s.getUpdateTag() == "volume") + { + cout << "received volume update for " << s.getKey() << ": " << s.getValue().volume << endl; + } + } + }; + + // Print out the sample values queued with this reader. + reader->onSamples( + [displaySample](const vector>& samples) + { + for (const auto& s : samples) + { + displaySample(s); + } + }, + displaySample); + + // Exit once the user hits Ctrl-C to shutdown the node. + node.waitForShutdown(); + } + catch (const std::exception& ex) + { + cerr << ex.what() << endl; + return 1; + } + return 0; +} diff --git a/cpp/DataStorm/stock/Stock.ice b/cpp/DataStorm/stock/Stock.ice new file mode 100644 index 000000000..1a8a1940c --- /dev/null +++ b/cpp/DataStorm/stock/Stock.ice @@ -0,0 +1,17 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +module Demo +{ + struct Stock + { + string name; + float price; + float bestBid; + float bestAsk; + long marketCap; + float previousClose; + int volume; + } +} diff --git a/cpp/DataStorm/stock/Writer.cpp b/cpp/DataStorm/stock/Writer.cpp new file mode 100644 index 000000000..04636b1d8 --- /dev/null +++ b/cpp/DataStorm/stock/Writer.cpp @@ -0,0 +1,162 @@ +// Copyright (c) ZeroC, Inc. All rights reserved. + +#include +#include + +#include "Stock.h" + +#include +#include +#include + +using namespace std; +using namespace Demo; + +namespace +{ + + std::random_device random; + + DataStorm::SingleKeyWriter + makeStock(DataStorm::Topic& topic, string ticker, Stock stock) + { + // Create a stock writer for the given ticker and add the initial stock value. + auto writer = DataStorm::makeSingleKeyWriter(topic, std::move(ticker)); + writer.add(std::move(stock)); + return writer; + } + + void updateStock(DataStorm::SingleKeyWriter& stock) + { + // Send a partial update to either update the price or the volume with the given writer. + if (uniform_int_distribution(1, 10)(random) < 8) + { + auto price = stock.getLast().getValue().price; + stock.partialUpdate("price")(uniform_real_distribution(price * 0.95f, price * 1.05f)(random)); + } + else + { + auto volume = stock.getLast().getValue().volume; + stock.partialUpdate("volume")( + uniform_int_distribution(volume * 95 / 100, volume * 105 / 100)(random)); + } + } + +} + +int +main(int argc, char* argv[]) +{ + try + { + // CtrlCHandler must be called before the node is created or any other threads are started. + Ice::CtrlCHandler ctrlCHandler; + + // Instantiates node. + DataStorm::Node node(argc, argv, "config.writer"); + + // Shutdown the node on Ctrl-C. + ctrlCHandler.setCallback([&node](int) { node.shutdown(); }); + + // Instantiates the "stock" topic. + DataStorm::Topic topic(node, "stocks"); + + // Setup partial update updaters. The updater is responsible for updating the element value when a partial + // update is received. Updaters must be set on both the topic reader and writer. + topic.setUpdater("price", [](Stock& stock, float price) { stock.price = price; }); + topic.setUpdater("volume", [](Stock& stock, int volume) { stock.volume = volume; }); + + // Setup a few stocks + cout << "Available stocks: " << endl; + map stocks{ + {"GOOG", + Stock{ + .name = "Google", + .price = 1040.61f, + .bestBid = 1035.0f, + .bestAsk = 1043.178f, + .marketCap = 723018024728, + .previousClose = 1035.96f, + .volume = 536996}}, + {"AAPL", + Stock{ + .name = "Apple", + .price = 174.74f, + .bestBid = 174.44f, + .bestAsk = 175.50f, + .marketCap = 898350570640, + .previousClose = 174.96f, + .volume = 14026673}}, + {"FB", + Stock{ + .name = "Facebook", + .price = 182.78f, + .bestBid = 180.29f, + .bestAsk = 183.15f, + .marketCap = 531123722959, + .previousClose = 180.87f, + .volume = 9426283}}, + {"AMZN", + Stock{ + .name = "Amazon", + .price = 1186.41f, + .bestBid = 1160.70f, + .bestAsk = 1186.84f, + .marketCap = 571697967142, + .previousClose = 1156.16f, + .volume = 3442959}}, + {"MSFT", + Stock{ + .name = "Microsoft", + .price = 83.27f, + .bestBid = 82.78f, + .bestAsk = 83.43f, + .marketCap = 642393925538, + .previousClose = 83.11f, + .volume = 6056186}}}; + + for (const auto& stock : stocks) + { + cout << stock.first << endl; + } + + string stockName; + cout << "Please enter the stock to publish (default = all):\n"; + getline(cin, stockName); + + // Instantiate writers for the choosen stocks. + vector> writers; + if (stockName.empty() || stockName == "all") + { + for (const auto& stock : stocks) + { + writers.push_back(makeStock(topic, stock.first, stock.second)); + } + } + else + { + if (stocks.find(stockName) == stocks.end()) + { + cout << "unknown stock `" << stockName << "'" << endl; + return 1; + } + writers.push_back(makeStock(topic, std::move(stockName), stocks[stockName])); + } + + // Update the stock value or volume attributes. + while (!node.isShutdown()) + { + this_thread::sleep_for(chrono::seconds(1)); + for (auto& w : writers) + { + updateStock(w); + } + } + } + catch (const std::exception& ex) + { + cerr << ex.what() << endl; + return 1; + } + return 0; +} diff --git a/cpp/DataStorm/stock/config.reader b/cpp/DataStorm/stock/config.reader new file mode 100644 index 000000000..4b5b781e4 --- /dev/null +++ b/cpp/DataStorm/stock/config.reader @@ -0,0 +1,26 @@ +# +# Use the localhost interface by default for DataStorm endpoints +# +Ice.Default.Host=localhost + +# +# DataStorm server endpoint +# +#DataStorm.Node.Server.Endpoints=tcp + +# +# DataStorm multicast endpoint +# +#DataStorm.Node.Multicast.Endpoints=udp -h 239.255.0.1 -p 10000 + +# +# DataStorm Tracing +# +#DataStorm.Trace.Topic=1 +#DataStorm.Trace.Data=1 +#DataStorm.Trace.Session=1 + +# +# Ice tracing +# +#Ice.Trace.Network=1 diff --git a/cpp/DataStorm/stock/config.writer b/cpp/DataStorm/stock/config.writer new file mode 100644 index 000000000..4b5b781e4 --- /dev/null +++ b/cpp/DataStorm/stock/config.writer @@ -0,0 +1,26 @@ +# +# Use the localhost interface by default for DataStorm endpoints +# +Ice.Default.Host=localhost + +# +# DataStorm server endpoint +# +#DataStorm.Node.Server.Endpoints=tcp + +# +# DataStorm multicast endpoint +# +#DataStorm.Node.Multicast.Endpoints=udp -h 239.255.0.1 -p 10000 + +# +# DataStorm Tracing +# +#DataStorm.Trace.Topic=1 +#DataStorm.Trace.Data=1 +#DataStorm.Trace.Session=1 + +# +# Ice tracing +# +#Ice.Trace.Network=1 diff --git a/cpp/DataStorm/stock/msbuild/reader/packages.config b/cpp/DataStorm/stock/msbuild/reader/packages.config new file mode 100644 index 000000000..a36cb289a --- /dev/null +++ b/cpp/DataStorm/stock/msbuild/reader/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/stock/msbuild/reader/reader.vcxproj b/cpp/DataStorm/stock/msbuild/reader/reader.vcxproj new file mode 100644 index 000000000..4fbbb4c1f --- /dev/null +++ b/cpp/DataStorm/stock/msbuild/reader/reader.vcxproj @@ -0,0 +1,129 @@ + + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + reader + {5550D94C-D162-4367-BF79-00243E79D3D1} + + + + Application + $(DefaultPlatformToolset) + true + + + + + ..\..\ + $(Platform)\$(Configuration)\ + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + + true + true + true + ..\..\Stock.ice + + + true + true + true + ..\..\Stock.ice + + + true + true + true + ..\..\Stock.ice + + + true + true + true + ..\..\Stock.ice + + + + + + + + + + true + true + true + ..\..\Stock.ice + + + true + true + true + ..\..\Stock.ice + + + true + true + true + ..\..\Stock.ice + + + true + true + true + ..\..\Stock.ice + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/stock/msbuild/reader/reader.vcxproj.filters b/cpp/DataStorm/stock/msbuild/reader/reader.vcxproj.filters new file mode 100644 index 000000000..36f0b5500 --- /dev/null +++ b/cpp/DataStorm/stock/msbuild/reader/reader.vcxproj.filters @@ -0,0 +1,97 @@ + + + + + {2f52ec5d-d778-4988-8746-1a2d17b17375} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {d096f6ce-e47c-430a-a7f7-7fe3c2fa047f} + h;hpp;hxx;hm;inl + + + {b3e66749-c970-4413-b670-910ee10bcb50} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {54205b3f-00cc-43c3-a647-1a97ac6e42d1} + + + {99d397d9-aeab-424e-a4b9-2feffe1e2a3c} + + + {830a71b6-c55e-43bf-bd39-35dd75f7598f} + + + {abe29213-40c1-42ae-82f6-13960f87f80f} + + + {b8bd02eb-ad99-4ea9-b35b-820b1515d024} + + + {6bb1313d-5f4c-4706-982c-bfd307049dff} + + + {eab958d6-2f01-4f7c-81f1-73a81116f6e7} + + + {d989c58c-b45d-4b52-8367-efbfb6c7c705} + + + {699475cb-4dca-47b4-a359-5e956d49fc4e} + + + {72211793-ecad-4716-9f97-efdd43d3cb16} + + + {161886eb-7d10-4b2e-b341-519c5bd46f3e} + + + {3bc3082d-1a19-40d7-86d5-16e38a32b43c} + + + {3f77fbb8-4e67-4db1-98b8-d24257c8fce1} + ice + + + + + Source Files + + + Source Files\Win32\Debug + + + Source Files\x64\Debug + + + Source Files\Win32\Release + + + Source Files\x64\Release + + + + + + + + + Header Files\Win32\Debug + + + Header Files\x64\Debug + + + Header Files\Win32\Release + + + Header Files\x64\Release + + + + + Slice Files + + + \ No newline at end of file diff --git a/cpp/DataStorm/stock/msbuild/reader/reader.vcxproj.user b/cpp/DataStorm/stock/msbuild/reader/reader.vcxproj.user new file mode 100644 index 000000000..af59416bd --- /dev/null +++ b/cpp/DataStorm/stock/msbuild/reader/reader.vcxproj.user @@ -0,0 +1,19 @@ + + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + \ No newline at end of file diff --git a/cpp/DataStorm/stock/msbuild/writer/packages.config b/cpp/DataStorm/stock/msbuild/writer/packages.config new file mode 100644 index 000000000..a36cb289a --- /dev/null +++ b/cpp/DataStorm/stock/msbuild/writer/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/stock/msbuild/writer/writer.vcxproj b/cpp/DataStorm/stock/msbuild/writer/writer.vcxproj new file mode 100644 index 000000000..15602e1a0 --- /dev/null +++ b/cpp/DataStorm/stock/msbuild/writer/writer.vcxproj @@ -0,0 +1,129 @@ + + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + writer + {4362D2DF-3F07-4248-9CB4-9682B29EE0D3} + + + + Application + $(DefaultPlatformToolset) + true + + + + + ..\..\ + $(Platform)\$(Configuration)\ + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + $(Platform)\$(Configuration) + + + + + + + + + true + true + true + ../../Stock.ice + + + true + true + true + ../../Stock.ice + + + true + true + true + ../../Stock.ice + + + true + true + true + ../../Stock.ice + + + + + + + true + true + true + ../../Stock.ice + + + true + true + true + ../../Stock.ice + + + true + true + true + ../../Stock.ice + + + true + true + true + ../../Stock.ice + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + \ No newline at end of file diff --git a/cpp/DataStorm/stock/msbuild/writer/writer.vcxproj.filters b/cpp/DataStorm/stock/msbuild/writer/writer.vcxproj.filters new file mode 100644 index 000000000..19d79d10a --- /dev/null +++ b/cpp/DataStorm/stock/msbuild/writer/writer.vcxproj.filters @@ -0,0 +1,97 @@ + + + + + {2f52ec5d-d778-4988-8746-1a2d17b17375} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {d096f6ce-e47c-430a-a7f7-7fe3c2fa047f} + h;hpp;hxx;hm;inl + + + {b3e66749-c970-4413-b670-910ee10bcb50} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {455cd0c2-e4a5-4c22-ad0d-70fb07649219} + + + {913e25a0-e91e-4c09-93a4-da1a70a92c3c} + + + {4d52a7fc-8c18-4b6a-9b20-b8bb4863728e} + + + {eeafc211-ec2a-4b0b-a88a-b9ee38642304} + + + {7753f830-8c8d-401c-a223-999c7d151052} + + + {03a64ef2-770b-4051-b00a-01985988b6d4} + + + {2a96e9d1-cbd2-4c64-8b5f-4b8655df936a} + + + {26e0ba27-61fb-4faf-811f-e0871cd7d9b4} + + + {d30b93dd-813e-42d6-9c0b-ead37f8733ad} + + + {3101e8aa-8e41-4ce2-ae1b-1fb66fb91868} + + + {cea25ac8-357a-4383-9d99-e566b90e67df} + + + {bc0c068e-d3ca-467d-be99-f5bce440a8d2} + + + {6eec9496-4f31-4f38-a861-1fc6d875fa9d} + ice + + + + + Source Files + + + Source Files\Win32\Debug + + + Source Files\x64\Debug + + + Source Files\Win32\Release + + + Source Files\x64\Release + + + + + + + + + Header Files\Win32\Debug + + + Header Files\x64\Debug + + + Header Files\Win32\Release + + + Header Files\x64\Release + + + + + Slice Files + + + \ No newline at end of file diff --git a/cpp/DataStorm/stock/msbuild/writer/writer.vcxproj.user b/cpp/DataStorm/stock/msbuild/writer/writer.vcxproj.user new file mode 100644 index 000000000..af59416bd --- /dev/null +++ b/cpp/DataStorm/stock/msbuild/writer/writer.vcxproj.user @@ -0,0 +1,19 @@ + + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + + ..\..\ + WindowsLocalDebugger + + \ No newline at end of file diff --git a/cpp/make/Make.rules b/cpp/make/Make.rules index 34f7e4bee..3dde6bbad 100644 --- a/cpp/make/Make.rules +++ b/cpp/make/Make.rules @@ -19,7 +19,7 @@ $(eval $(call validate-config)) # # Support for Ice libraries # -cpp-dependencies = Ice Glacier2 IceGrid IcePatch2 IceSSL IceDiscovery IceLocatorDiscovery IceStorm IceBox +cpp-dependencies = Ice Glacier2 IceGrid DataStorm IceDiscovery IceLocatorDiscovery IceStorm IceBox Ice_libs = bz2 Glacier2_dependencies = Ice IceGrid_dependencies = Glacier2 Ice @@ -61,7 +61,7 @@ $1_srcext := cpp $1_dependencies := $$(or $$($1_dependencies),Ice) $1_slicecompiler := slice2cpp $1_sliceflags := -I$(ice_slicedir) -I$1 $$($1_sliceflags) -$1_cppflags := -DICE_CPP11_MAPPING -std=c++17 -I$1 -I$1/generated $(ice_cppflags) $$($1_cppflags) +$1_cppflags := -std=c++17 -I$1 -I$1/generated $(ice_cppflags) $$($1_cppflags) $1_caninstall := no # Also link with IceSSL, IceDiscovery and IceLocatorDiscovery when compiling the project with the static configuration diff --git a/make/Make.demos.rules b/make/Make.demos.rules index 0b6ac2d84..1de566801 100644 --- a/make/Make.demos.rules +++ b/make/Make.demos.rules @@ -21,7 +21,7 @@ demo-sources = $(call unique,$(if $1,$(foreach f,$1,$(notdir $(wildcard $2/$f))) # # The demo executables to try to build in each demo directory # -demo-programs = client server publisher subscriber +demo-programs = client server publisher subscriber reader writer # # The default demo sources for each demo executable. @@ -30,6 +30,8 @@ demo-client-sources = Client.$1 *.ice demo-server-sources = Server.$1 *.ice *I.$1 demo-publisher-sources = Publisher.$1 *.ice demo-subscriber-sources = Subscriber.$1 *.ice +demo-writer-sources = Writer.$1 *.ice +demo-reader-sources = Reader.$1 *.ice # # $(call create-demo-project,demo) @@ -71,6 +73,12 @@ $1_publisher_sources := $$(call demo-sources,$$(call $1_publisher_sources,$$( $1_subscriber_sources := $$(call demo-sources,$$(call $1_subscriber_sources,$$($1_srcext)),$$($1_srcdir),\ $$(call demo-subscriber-sources,$$($1_srcext))) +$1_writer_sources := $$(call demo-sources,$$(call $1_writer_sources,$$($1_srcext)),$$($1_srcdir),\ + $$(call demo-writer-sources,$$($1_srcext))) + +$1_reader_sources := $$(call demo-sources,$$(call $1_reader_sources,$$($1_srcext)),$$($1_srcdir),\ + $$(call demo-reader-sources,$$($1_srcext))) + $1_programs := $$(foreach p,$$($1_programs),$$(if $$($1_$$(p)_sources),$1_$$(p))) $1_libraries := $$(foreach p,$$($1_libraries),$1_$$(p))