C++ Builder supports the Variadic templates. Variadic templates are template that take a variable number of arguments. Both the classes and functions can be variadic offered by C++11. Templates have been a powerful feature in C++. Now, after the introduction of variadic templates, templates have proven themselves even more powerful. Variadic templates are a trustworthy solution to implement delegates and tuples. Here’s a variadic class template: template class VariadicTemplate {}; templatetypename… Arguments> class VariadicTemplate {}; Any of the following ways to create an instance of this class template is valid: VariadicTemplate instance; VariadicTemplate instance; VariadicTemplate, std::string, std::string, std::vector> instance; VariadicTemplatedouble, float> instance; VariadicTemplatebool, unsigned short int, long> instance; VariadicTemplatechar, std::vectorint>, std::string, std::string, std::vectorlong long>> instance; Here’s a function template: template void SampleFunction(Arguments… parameters) {}; template void SampleFunction(Arguments… parameters) {}; The contents of the variadic template arguments are called parameter packs. These packs will then be unpacked inside the function parameters. For example, if you create a function call to the above variadic function template, SampleFunction(16, 24); SampleFunctionint, int>(16, 24); an equivalent function template would be like this: template void SampleFunction(T param1, U param2){}; templatetypename T, typename U> void SampleFunction(T param1, U param2){}; Head over and find out more about C++ variadic templates in the Embarcadero DocWiki!
In this session, you can see and listen to a conversation with C++ designer, Bjarne Stroustrup. Overview ISO/IEC 14882-2011 aka C++11, formerly “C++0x” How C++ 11 builds on C++’s strengths How C++ 11 makes C++ easier to Application portability C++’s ubiquitous presence in the markets About Bjarne Stroustrup Designer and original implementor of C++ Distinguished Professor and holder of the College of Engineering Chair in Computer Science, Texas A&M Member, the C++ standards committee When is the right time to start a language standard? What’s like to work on the C++ standard with others from the industry and academia? Bjarne Stroustrup has shown his views on C++. And how the C++ designed, what things were the influence for the creation of the C++ language. What are some of the key areas that help make C++ easier to use? Is inheritance overused? Be sure to watch the whole session to get a deep understanding of C++ language!
Embarcadero Bcc32c and bcc32x (Clang-enhanced compiler for Win32) implements all of the ISO C++11 standard. It includes the use of non-static data member to be initialized where it is declared. The basic idea for C++11 is to allow a non-static data member to be initialized where it is declared (in its class). A constructor can then use the initializer when run-time initialization is needed. #include struct B { B(int, double, double); }; class A { int a = 7; // OK std::string str1 = “member”; // OK B b = {1, 2, 3.0}; //OK std::string str2(“member”); // ill-formed }; #include struct B { B(int, double, double); }; class A { int a = 7; // OK std::string str1 = “member”; // OK B b = {1, 2, 3.0}; //OK std::string str2(“member”); // ill-formed }; Why useful.-Easier to write.-You are sure that each member is properly initialized.-You cannot forget to initialize a member like when having a complicated constructor. Initialization and declaration are in one place – not separated.-Especially useful when we have several constructors.-Previously we would have to duplicate initialization code for members.-Now, you can do a default initialization and constructors will only do its specific jobs. If a member is initialized by both an in-class initializer and a constructor, only the constructor’s initialization is done (it “overrides” the default). Head over and find out more about C++ non-static data member initializers in the Embarcadero DocWiki!
function TForm1.GetProperty(pSelf, Args : PPyObject) : PPyObject; cdecl; var key : PAnsiChar; begin with GetPythonEngine do if PyArg_ParseTuple( args, ‘s:GetProperty’,@key ) > 0 then begin if key = ‘Title’ then Result := VariantAsPyObject(cbTitle.Text) else if key = ‘Name’ then Result := VariantAsPyObject(edName.Text) else if key = ‘Informatician’ then Result := VariantAsPyObject(cbInformatician.Checked) else if key = ‘PythonUser’ then Result := VariantAsPyObject(cbPythonUser.Checked) else if key = ‘Age’ then Result := VariantAsPyObject(edAge.Text) else if key = ‘Sex’ then Result := VariantAsPyObject(rgSex.ItemIndex) else begin PyErr_SetString (PyExc_AttributeError^, PAnsiChar(Format(‘Unknown property “%s”‘, [key]))); Result := nil; end; end else Result := nil; end; function TForm1.SetProperty(pSelf, Args : PPyObject) : PPyObject; cdecl; var key : PAnsiChar; value : PPyObject; begin with GetPythonEngine do if PyArg_ParseTuple( args, ‘sO:SetProperty’,@key, @value ) > 0 then begin if key = ‘Title’ then begin cbTitle.Text := PyObjectAsVariant( value ); Result := ReturnNone; end else if key = ‘Name’ then begin edName.Text := PyObjectAsVariant( value ); Result := ReturnNone; end else if key = ‘Informatician’ then begin cbInformatician.Checked := PyObjectAsVariant( value ); Result := ReturnNone; end else if key = ‘PythonUser’ then begin cbPythonUser.Checked := PyObjectAsVariant( value ); Result := ReturnNone; end else if key = ‘Age’ then begin edAge.Text := PyObjectAsVariant( value ); Result := ReturnNone; end else if key = ‘Sex’ then begin rgSex.ItemIndex := PyObjectAsVariant( value ); Result := ReturnNone; end else begin PyErr_SetString (PyExc_AttributeError^, PAnsiChar(Format(‘Unknown property “%s”‘, [key]))); Result := nil; end; end else Result := nil; end;
We know Delphi supports Multithreading. Multithreading in Python can be achieved using Python Module Threading. However, In a use case like Delphi Application embedding Python(Python4Delphi) or CPython, the interpreter is not fully thread-safe. In order to support multi-threaded Python programs, there’s a global lock, called the global interpreter lock or GIL, that must be held by the current thread before it can safely access Python objects. Locking the entire interpreter makes it easier for the interpreter to be multi-threaded, at the expense of much of the parallelism afforded by multi-processor machines. Some extension modules, either standard or third-party, are designed so as to release the GIL when doing computationally-intensive tasks such as compression or hashing. Also, the GIL is always released when doing I/O. More Details here. This post will guide you on how to evaluate several python functions concurrently using Python4Delphi TPyDelphiThread. Python4Delphi Demo11 Sample App shows how to achieve concurrency(using more interpreters) inside Python. You can find the Demo11 source on GitHub. Prerequisites: Download and install the latest Python for your platform. Follow the Python4Delphi installation instructions mentioned here. Alternatively, you can check out this video Getting started with Python4Delphi. Components used in Python4Delphi Demo11 App: TPythonEngine: A collection of relatively low-level routines for communicating with Python, creating Python types in Delphi, etc. It’s a singleton class. TPythonModule: It’s inherited from TMethodsContainer class allows creating modules by providing a name. You can use routines AddMethod, AddMethodWithKW to add a method of type PyCFunction. You can create events using the Events property. TPaintBox provides a canvas that applications can use for rendering an image. TPyDelphiThread: Inherited from TThread has properties like ThreadState( A pointer which stores Python last state), ThreadExecMode(emNewState, emNewInterpreter). Protected functions like ExecuteWithPython, Py_Begin_Allow_Threads, Py_End_Allow_Threads helps to run concurrently without thread conflicts. TMemo: A multiline text editing control, providing text scrolling. The text in the memo control can be edited as a whole or line by line. You can find the Python4Delphi Demo11 sample project from the extracted GitHub repository ..Python4DelphiDemosDemo11.dproj. Open this project in RAD Studio 10.4.1 and run the application. Implementation Details: PythonEngine component provides the connection to Python or rather the Python API. This project uses Python3.9 which can be seen in TPythonEngine DllName property. SortModule(TPythonModule) has initialized with 2 Delphi Methods SortModule_GetValue, SortModule_Swap which is imported in python script to perform sorting. 3 arrays are randomized with integer values, later get sorted. Three Sort functions were defined in the script such as BubbleSort, SelectionSort, and QuickSort which is evaluated by PyDelphiThread Instance’s ExecuteWithPython procedure. Note: Don’t override Execute Method, use always ExecuteWithPython. In this Sample, one interpreter Button uses an emNewState(single interpreter with new state and upon execution completion, restores the thread state) ThreadExecMode and three interpreter button use an emNewInterpreter (same as a new state but with new interpreter fully initialized) ThreadExecMode to Execute. procedure TThreadSortForm.InitThreads(ThreadExecMode: TThreadExecMode; script: TStrings); begin RandomizeArrays; ThreadsRunning := 3; with GetPythonEngine do begin OwnThreadState := PyEval_SaveThread; with TSortThread.Create( ThreadExecMode, script, SortModule, ‘SortFunc1’, BubbleSortBox, BubbleSortArray) do OnTerminate := ThreadDone; with TSortThread.Create( ThreadExecMode, script, SortModule, ‘SortFunc2’, SelectionSortBox, SelectionSortArray) do OnTerminate := ThreadDone; with TSortThread.Create( ThreadExecMode, script, SortModule, ‘SortFunc3’, QuickSortBox, QuickSortArray) do OnTerminate := ThreadDone; end; StartBtn.Enabled := False; Start2Btn.Enabled := False; end; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 procedure TThreadSortForm.InitThreads(ThreadExecMode: TThreadExecMode; script: TStrings); begin RandomizeArrays; ThreadsRunning := 3; with GetPythonEngine do begin […]
In this FireMonkey App Settings template, you can find three different multi-device templates. And you can learn how to create and design FireMonkey user interfaces. Available on C++ Builder and Delphi Moreover, you can learn how to utilize several components together to make meaningful components. And applying different styles and creating frames to make fast and reliable user interfaces with FireMonkey. You can get these complete FireMonkey UI templates from GetIt Package Manager Be sure to check out another industry FireMonkey UI templates: Be sure to check out all the available sample applications here!
Its already late and time to modernize your Delphi/C++ Application with extensive Windows 10 support, as the support for Windows 7 ended on January 14, 2020. Rad Studio offers robust components and visually stunning styles to modernize your existing applications in Windows 10. This post will give overview some of the Windows 10 specific features introduced in RAD Studio. Features Overview: Quickly and Easily update VCL and FMX applications to Windows 10 with the Windows 10 Controls. Address common UI Paradigms on Windows 10. Range of UI controls specifically designed for windows 10. Built in windows 10 styles for both VCL and FireMonkey applications. Select custom styles for VCL and FireMonkey available for download in GetIt. VCL extensions for HI-DPI, 4k monitors Support. Rad Studio 10.3 includes PerMonitorV2, Multi Resolutions Image List support. Expanded WinRT API and Windows store support. Windows 10 uses Segoe as the Standard font. Some font guidelines which can make your application looks windows 10. Header – Segoe UI Light,46 pt. Sub Header – Segoe UI Light,34 pt. Title– Segoe UI Semi Light,24 pt. Subtitle – Segoe UI Normal,20 pt. Base – Segoe UI Semi Bold 15 pt. Body -Segoe UI Normal,15 pt. Caption -Segoe UI Normal,12 pt. Windows 10 VCL Controls : TSplitView : A container for other controls that can be opened and closed similar to the TMultiView in FireMonkey. When opened, TSplitView can be docked to the left or right edge of the form, or displayed on top of the client area of the form (overlayed). When closed, the TSplitView can be completely hidden (CloseStyle = svcCollapse), or a smaller portion of the split view can remain visible (CloseStyle = svcCompact). TRelativePanel : A container control that allows you to position child controls relative to the panel itself or relative to other child controls of this panel. For more information on how to use the relative panel, see Using the Relative Panel. TToggleSwitch : A clickable control that allows a user to toggle between an On state and an Off state. Flexible to change the caption of the state. TDatePicker and TTimePicker : Control to let users specify a date and time from a pop-up scrolling list of values. TCalenderView : Allows you to customize the look-and-feel of the control. It supports the selection of multiple dates and includes the Month, Year, Decade views. TCardpanel : Use the TCardPanel to manage a collection of cards. Each card is a container for other controls and only one card is active/visible at a time. TStackPanel : Use the TStackPanel to apply homogeneous alignment, margin, and padding settings to a series of controls inside a panel container. Windows 10 Styles For VCL and FireMonkey. You can apply styles to your application to have stunning look and feel. Some of the windows 10 specific styles were built in to the RAD studio. You can check by navigating to Project->Options->Application->Appearance->select some the styles and you can preview the styles as well. Alternatively you can get some VCL and FireMonkey Styles from Tools->Getit Package manger-> Under Styles category-> select the styles which you wish to apply to your application. You also have flexibility to create your own custom styles using the Tools-> BitMap Style Designer. Check the Video New UX Design Principles for RAD Studio Developers in Windows for Demonstration below. Check out the High DPI Styles and VCL Styling Per Control feature introduced in […]
Take your Delphi and C++Builder projects to the next level using the IBM Watson REST API, a collaborative environment with AI tools that you can use to deploy machine learning models and training data. In this webinar, you can learn how to use IBM Watson APIs to make AI applications with your Delphi or C++ Builder applications. Overview of this session: Delphi & C++ Builder Integration with Web and REST Services HTTP native client library SOAP clients REST clients BaaS clients Cloud API IBM Watson AI Services Visual Recognition Tone Analysis (Natural Language Classification) Watson Machine Learning What you can do with Watson APIs Speech to Text – Text to Speech NLP Knowledge Studio Visual Recognition Language Translator Language Classifier AI for IT Operations AI for Customer Service and more Infuse AI in your Delphi and C++ Builder applications to make more accurate predictions, automate processes, and decisions. Be sure to watch the whole session to learn the demos in action and learn best practices!
In this short tutorial, C++ Product Manager, David Millington, explains what event handlers are and how to use them in your C++ application development. Overview The event is that something happens. Event handler – a method that’s called when something happens or is attached to an event. Technical details: an object-method pointer, referring to both the method and object instance on which to call the method. And it can have any signature. Defining Event Handlers In an event receiver class, you define event handlers, which are methods with signatures for instance: return types, calling conventions, and arguments that match the event that they will handle. Firing Events To fire an event, simply call the method declared as an event in the event source class. If handlers have been hooked to the event, the handlers will be called. Be sure to check out other tutorials on C++ Builder here:
Invormațiile pe cale Dvs le introduceți în prezentul formular nu se păstrează online, dar se vor transmite direct la destinație. Mai multe informații găsiți în Politica Noastră de Confidentialitate
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.