Re: [fpc-pascal] Adding method dynamically to a class
On Wed, Jun 20, 2012 at 8:33 AM, LacaK la...@zoznam.sk wrote: ** Class helpers would not help ? http://wiki.freepascal.org/Helper_types They can, but there is a protocol that I'm trying to create that provides me information what to execute (out of white list). The thing is, that the first request maps the methods to be used, and there could be 2 or 200. To implement 200 methods that might be used is not a good idea imho, but adding the proper method to the instance/class will work much better. It's easy to do in dynamic language, and I might need to implement it there instead :( -Laco. Hello, Is there a way to tell in run-time that a specific function/procedure should belong to a class ? For example, let's say I have the following class: Type TTest = class procedure Foo; end; And I have also: procedure Bar; ... end; ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Adding method dynamically to a class
On Wed, 20 Jun 2012, ik wrote: On Wed, Jun 20, 2012 at 8:33 AM, LacaK la...@zoznam.sk wrote: ** Class helpers would not help ? http://wiki.freepascal.org/Helper_types They can, but there is a protocol that I'm trying to create that provides me information what to execute (out of white list). The thing is, that the first request maps the methods to be used, and there could be 2 or 200. To implement 200 methods that might be used is not a good idea imho, but adding the proper method to the instance/class will work much better. I don't understand this argument. The available methods must have an implementation somewhere anyway. That means your code does not get smaller by adding them dynamically. Somewhere you must choose which method to execute, and whether it is allowed or not, so this logic must be present also. None of this requires dynamically adding methods as far as I can see, or is made easier by dynamically adding methods. So finally, what is gained by adding them dynamically ? Or what forces you to even consider this path ? Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE : [fpc-pascal] Adding method dynamically to a class
They can, but there is a protocol that I'm trying to create that provides me information what to execute (out of white list). The thing is, that the first request maps the methods to be used, and there could be 2 or 200. To implement 200 methods that might be used is not a good idea imho, but adding the proper method to the instance/class will work much better. It's easy to do in dynamic language, and I might need to implement it there instead :( Can't you create a stub that executes your variable methods/functions? Something like Type TTest = class procedure Foo; procedure NewMethod(MethodName:string; MethodAddress:TProcedureOfObject); procedure Call(MethodName:string) end; NewMethod stores the name + method address in fe. a StringList. Call just looks up the method and executes it. The method will receive the Self of the TTest instance which is what you want. Ludo ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Adding method dynamically to a class
On Wed, Jun 20, 2012 at 10:20 AM, michael.vancann...@wisa.be wrote: On Wed, 20 Jun 2012, ik wrote: On Wed, Jun 20, 2012 at 8:33 AM, LacaK la...@zoznam.sk wrote: ** Class helpers would not help ? http://wiki.freepascal.org/**Helper_typeshttp://wiki.freepascal.org/Helper_types They can, but there is a protocol that I'm trying to create that provides me information what to execute (out of white list). The thing is, that the first request maps the methods to be used, and there could be 2 or 200. To implement 200 methods that might be used is not a good idea imho, but adding the proper method to the instance/class will work much better. I don't understand this argument. The available methods must have an implementation somewhere anyway. That means your code does not get smaller by adding them dynamically. Somewhere you must choose which method to execute, and whether it is allowed or not, so this logic must be present also. None of this requires dynamically adding methods as far as I can see, or is made easier by dynamically adding methods. So finally, what is gained by adding them dynamically ? Or what forces you to even consider this path ? Think of a plug-able system. I have an engine, and code to execute. Instead of compile everything to an ELF/PE, I place code on dynamic shard library, and load it on run time when needed. The idea is that the engine will not be rewritten for every new request (that comes often), because it's logic (almost) never changes, but to load code on demand that often changes, provide additional functions, changes of logic, bug fixes etc... The idea of implementing it like so, came to me after few years now of having the need to recreate the whole logic based of the code for every new demand from the client (both as human, and as software). The main code almost never changes, but so many additions, that I'm starting to use the dynamic execution of methods, and now I realize, that if I'll extract it to a shard library, it will be much easier to change, add etc... only the actual need, and not to touch other stuff, and that requires me to design an engine instead. Regardless of that idea, it can be very interesting in learning how to do it imho :) Michael Ido __**_ fpc-pascal maillist - fpc-pascal@lists.freepascal.**orgfpc-pascal@lists.freepascal.org http://lists.freepascal.org/**mailman/listinfo/fpc-pascalhttp://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Adding method dynamically to a class
I suggest that you implement this using interfaces. You place the interface declaration in a common file, use the interfaces from the main exe but implement them in separate dlls. This gives you all the flexibility you want, e.g. group your methods into bundles and place them on different interfaces. You will only need a class identifying system (i.e. a class id string) that will be known to the exe and implementing dlls and a factory exported function in each dll that creates the implementing object of a known class id. You can have many alternate implementations of an interface with different class ids and you can even replace an implementing dll with another version of it with bug fixes or even different functionality. In my mind it is always Plugin System == Interfaces. HTH. On Wed, Jun 20, 2012 at 11:14 AM, ik ido...@gmail.com wrote: The idea of implementing it like so, came to me after few years now of having the need to recreate the whole logic based of the code for every new demand from the client (both as human, and as software). The main code almost never changes, but so many additions, that I'm starting to use the dynamic execution of methods, and now I realize, that if I'll extract it to a shard library, it will be much easier to change, add etc... only the actual need, and not to touch other stuff, and that requires me to design an engine instead. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Adding method dynamically to a class
On Wed, 20 Jun 2012, ik wrote: On Wed, Jun 20, 2012 at 10:20 AM, michael.vancann...@wisa.be wrote: On Wed, 20 Jun 2012, ik wrote: On Wed, Jun 20, 2012 at 8:33 AM, LacaK la...@zoznam.sk wrote: ** Class helpers would not help ? http://wiki.freepascal.org/**Helper_typeshttp://wiki.freepascal.org/Helper_types They can, but there is a protocol that I'm trying to create that provides me information what to execute (out of white list). The thing is, that the first request maps the methods to be used, and there could be 2 or 200. To implement 200 methods that might be used is not a good idea imho, but adding the proper method to the instance/class will work much better. I don't understand this argument. The available methods must have an implementation somewhere anyway. That means your code does not get smaller by adding them dynamically. Somewhere you must choose which method to execute, and whether it is allowed or not, so this logic must be present also. None of this requires dynamically adding methods as far as I can see, or is made easier by dynamically adding methods. So finally, what is gained by adding them dynamically ? Or what forces you to even consider this path ? Think of a plug-able system. I have an engine, and code to execute. Instead of compile everything to an ELF/PE, I place code on dynamic shard library, and load it on run time when needed. The idea is that the engine will not be rewritten for every new request (that comes often), because it's logic (almost) never changes, but to load code on demand that often changes, provide additional functions, changes of logic, bug fixes etc... The idea of implementing it like so, came to me after few years now of having the need to recreate the whole logic based of the code for every new demand from the client (both as human, and as software). The main code almost never changes, but so many additions, that I'm starting to use the dynamic execution of methods, and now I realize, that if I'll extract it to a shard library, it will be much easier to change, add etc... only the actual need, and not to touch other stuff, and that requires me to design an engine instead. This is understandable, but none of this explains why you would need to add a method to a class ? I have a similar system, but do not need to add methods to a class ? Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Adding method dynamically to a class
In our previous episode, kyan said: I suggest that you implement this using interfaces. You place the interface declaration in a common file, use the interfaces from the main exe but implement them in separate dlls. Or maybe go a step further, and use IDispatch that passes through unknown methods to handler functions in the loaded dynamic libraries. This will also allow some freedom in the parameter lists of added functions. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Converting from seconds to TTime: easiest way?
Morning list, I'm trying to convert a large number of seconds to a TTime. To my surprise - without a Delphi background ;) - EncodeTime only takes up to 59 seconds... ;) Same for EncodeTimeInterval So I ended up with something like: IncSecond(EncodeTime(0,0,0,0), HugeNumberOfSecondsInteger); is this the best way to do this or is there some smarter way I've missed? Thanks, Reinier ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Converting from seconds to TTime: easiest way?
Reinier Olislagers wrote: Morning list, I'm trying to convert a large number of seconds to a TTime. To my surprise - without a Delphi background ;) - EncodeTime only takes up to 59 seconds... ;) Same for EncodeTimeInterval Considering that TTime is a float where the fractional part is the part of a day, I would do it like this: MyTTime := HugeNumberOfSecondsInteger / (24 * 60 * 60); There might even be a constant somewhere called SecondsPerDay that would save you the writing of the denominator. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Converting from seconds to TTime: easiest way?
Try MyTTime := HugeNumberOfSecondsInteger / (3600 * 24); On 20 jun '12, Reinier Olislagers wrote: Morning list, I'm trying to convert a large number of seconds to a TTime. To my surprise - without a Delphi background ;) - EncodeTime only takes up to 59 seconds... ;) Same for EncodeTimeInterval So I ended up with something like: IncSecond(EncodeTime(0,0,0,0), HugeNumberOfSecondsInteger); is this the best way to do this or is there some smarter way I've missed? Thanks, Reinier ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org [1] http://lists.freepascal.org/mailman/listinfo/fpc-pascal [2] Links: -- [1] mailto:fpc-pascal@lists.freepascal.org [2] http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Converting from seconds to TTime: easiest way?
On 20-6-2012 11:53, dhkblas...@zeelandnet.nl wrote: Try MyTTime := HugeNumberOfSecondsInteger / (3600 * 24); Bedankt, Darius. That's indeed shorter and fairly clear... but the advantage of the other way is that I don't need to remember what units TTime uses internally... ;) Regards, Reinier ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpimage blur
On Fri, 1 Jun 2012 09:32:22 +0200 Mattias Gaertner nc-gaert...@netcologne.de wrote: On Thu, 31 May 2012 20:42:35 +0100 Graeme Geldenhuys graemeg.li...@gmail.com wrote: [...] Alternatively, AggPas also has many filter/blur/interpolation functions available. There are a few AggPas demos showing this in action. Yep, Aggpas seems to have the right algorithm. Thanks, this gives me some ideas to continue. fpc has now a new unit fpimggauss, with a normal Gaussian blur and a fast binominal Gaussian blur. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Creating video files
In my opinion, the easiest way is to create a series of BMP's and then use VirtualDub or VirtualDubMod (I think it's at Sourceforge). Greetings - Original Message - From: Krzysztof dib...@wp.pl To: fpc-pascal fpc-pascal@lists.freepascal.org Sent: Tuesday, June 19, 2012 3:53 PM Subject: [fpc-pascal] Creating video files Hi, I would like to write video (created from series of bitmaps) to some popular video formats like avi, flv. Is this possible? Has FPC bindings for video librarys? I googled that WinFF (http://winff.org/html_new/) is written in FPC and Lazarus, so I supose that some bindings exists but can't find any in http://wiki.freepascal.org/Multimedia_Programming Regards. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Adding method dynamically to a class
Think of a plug-able system. I have an engine, and code to execute. Instead of compile everything to an ELF/PE, I place code on dynamic shard library, and load it on run time when needed. The idea is that the engine will not be rewritten for every new request (that comes often), because it's logic (almost) never changes, but to load code on demand that often changes, provide additional functions, changes of logic, bug fixes etc... WST library server implementation could be a elegant solution : it is web-services that are locally located in dynamic library(DLL)/shared object(so) instead of being remote. The main executable acts as client while the server's implementation as provided as shared objects. No TCP is used, only memory through the WST's library protocol. No SOAP serialization as you can use the WST's custom binary messaging format that is very fast. To resume : * The main executable defines a WSDL schema that contains the types (think of this as IDL) * The servers implement the service exposed in the schema. * The main executable loads the servers using the library protocol Main benefits are : * much larger type system available (wsdl, WST contains a type library editor) * you could later even add remote servers without changing your main application, just create the service with the desired location parameters. -- Inoussa O. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Creating video files
Hmm, external application is nice idea. But VirtualDub is windows only. Anyone know multi-platform comandline video converter? What I found is Mencoder. I must test it 2012/6/20 Gerhard Scholz g...@g--s.de: In my opinion, the easiest way is to create a series of BMP's and then use VirtualDub or VirtualDubMod (I think it's at Sourceforge). Greetings - Original Message - From: Krzysztof dib...@wp.pl To: fpc-pascal fpc-pascal@lists.freepascal.org Sent: Tuesday, June 19, 2012 3:53 PM Subject: [fpc-pascal] Creating video files Hi, I would like to write video (created from series of bitmaps) to some popular video formats like avi, flv. Is this possible? Has FPC bindings for video librarys? I googled that WinFF (http://winff.org/html_new/) is written in FPC and Lazarus, so I supose that some bindings exists but can't find any in http://wiki.freepascal.org/Multimedia_Programming Regards. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Creating video files
Apart from _the_ multi-platform commandline video converter, ffmpeg? http://ffmpeg.org/ It's the back-end for WinFF (and most other utilities like these). Also, I would expect VirtualDub to run fine with WINE. -Flávio On Wed, Jun 20, 2012 at 11:00 AM, Krzysztof dib...@wp.pl wrote: Hmm, external application is nice idea. But VirtualDub is windows only. Anyone know multi-platform comandline video converter? What I found is Mencoder. I must test it 2012/6/20 Gerhard Scholz g...@g--s.de: In my opinion, the easiest way is to create a series of BMP's and then use VirtualDub or VirtualDubMod (I think it's at Sourceforge). Greetings - Original Message - From: Krzysztof dib...@wp.pl To: fpc-pascal fpc-pascal@lists.freepascal.org Sent: Tuesday, June 19, 2012 3:53 PM Subject: [fpc-pascal] Creating video files Hi, I would like to write video (created from series of bitmaps) to some popular video formats like avi, flv. Is this possible? Has FPC bindings for video librarys? I googled that WinFF (http://winff.org/html_new/) is written in FPC and Lazarus, so I supose that some bindings exists but can't find any in http://wiki.freepascal.org/Multimedia_Programming Regards. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Creating video files
Ffmpeg looks similar like Mencoder project. So I have some solutions for output encoding, but there is a problem how to send frames to this encoders. Mencoder can encode video from series of PNG files, but can't find similar option in ffmpeg. Anyone know something about RAW video format? It seems that this is some standard and most of players / encoders can handle it. I could use it as input for ffmpeg/mencoder but need some bindings / tips for FPC 2012/6/20 Flávio Etrusco flavio.etru...@gmail.com: Apart from _the_ multi-platform commandline video converter, ffmpeg? http://ffmpeg.org/ It's the back-end for WinFF (and most other utilities like these). Also, I would expect VirtualDub to run fine with WINE. -Flávio On Wed, Jun 20, 2012 at 11:00 AM, Krzysztof dib...@wp.pl wrote: Hmm, external application is nice idea. But VirtualDub is windows only. Anyone know multi-platform comandline video converter? What I found is Mencoder. I must test it 2012/6/20 Gerhard Scholz g...@g--s.de: In my opinion, the easiest way is to create a series of BMP's and then use VirtualDub or VirtualDubMod (I think it's at Sourceforge). Greetings - Original Message - From: Krzysztof dib...@wp.pl To: fpc-pascal fpc-pascal@lists.freepascal.org Sent: Tuesday, June 19, 2012 3:53 PM Subject: [fpc-pascal] Creating video files Hi, I would like to write video (created from series of bitmaps) to some popular video formats like avi, flv. Is this possible? Has FPC bindings for video librarys? I googled that WinFF (http://winff.org/html_new/) is written in FPC and Lazarus, so I supose that some bindings exists but can't find any in http://wiki.freepascal.org/Multimedia_Programming Regards. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Creating video files
Il 20/06/2012 19:22, Krzysztof ha scritto: Ffmpeg looks similar like Mencoder project. So I have some solutions for output encoding, but there is a problem how to send frames to this encoders. Mencoder can encode video from series of PNG files, but can't find similar option in ffmpeg. | || That's the command line to convert a png file image to a mpeg2 video format, using ffmpeg:| || |ffmpeg -f image2 -vcodec png -i menu.png -target pal-dvd -vcodec mpeg2video -an menu.mpeg| || |this makes me believe that the ffmpeg libraries should provide all what's required.| || |Giuliano| || | | ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Converting from seconds to TTime: easiest way?
Am 20.06.2012 12:16, schrieb Reinier Olislagers: On 20-6-2012 11:53, dhkblas...@zeelandnet.nl wrote: Try MyTTime := HugeNumberOfSecondsInteger / (3600 * 24); Bedankt, Darius. That's indeed shorter and fairly clear... but the advantage of the other way is that I don't need to remember what units TTime uses internally... ;) You could rely on constants provided by the dateutils unit (I'm rather sure that we'd provide approbiate replacements if we'd change the TDateTime type somewhen ;) ): MyTTime := HugeNumberOfSecondsInteger * OneSecond; Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Converting from seconds to TTime: easiest way?
2012/6/20 dhkblas...@zeelandnet.nl: Try MyTTime := HugeNumberOfSecondsInteger / (3600 * 24); MyTTime := HugeNumberOfSecondsInteger / SecsPerDay; The predefined constants from SysUtils look nicer. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal