Mailinglist Archive: zypp-devel (68 mails)
| < Previous | Next > |
[zypp-devel] Re: some RAII hint
- From: Michael Andres <ma@xxxxxxx>
- Date: Thu, 3 May 2007 12:11:22 +0200
- Message-id: <20070503101122.GA7160@xxxxxxx>
On Wed, May 02, Michael Andres wrote:
> USE RAII
> http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
>
> Resource Acquisition Is Initialization, often referred to by the acronym RAII,
> is a popular programming technique in C++ and D. The technique
> combines acquisition and release of resources with initialization and
> uninitialization of variables.
libzypp/doc/autodoc/html/group__g__RAII.html
(Icomplete like most docs ;( Fell free to add and update it. )
class zypp::DtorReset
Assign a vaiable a certain value when going out of scope
class zypp::base::Fd
Assert close called on open filedescriptor
struct zypp::str::SafeBuf
Assert free called for allocated char *
Some more examples, not (yet) listed:
zypp::AutoDispose< _Tp >
Reference counted access to a _Tp object calling a custom Dispose
function when the last AutoDispose handle to it is destroyed or reset.
Sounds more complicated than it actually is. See the
AutoDispose<const Pathname> example for exception safe
handling of temporary files.
Used eg. to return the binary rpm retrieved from some media.
Dependent on the type of media (downladed or not), and the
way it was retrieved, we need different kinds of
Of course: libzypp/doc/autodoc/html/group__ZYPP__SMART__PTR.html
zypp::filesystem::TmpFile
Provide a new empty temporary file and delete it when no longer
needed.
zypp::filesystem::TmpDir
Provide a new empty temporary directory and recursively delete it
when no longer needed.
None of these is complete or perfect. But we have at least some solutions
for some problems.
But they don't help if they are not used.
If you're looking for a solution and don't find it, ask for it. Maybe
something is there and you did not find it. If not, it's probabely
worth creating or improving something.
I know, more common solutions take a bit longer in the beginning. But
they soon outperform any copy-and-paste code.
Don't try to write as much code as you can. Only as much as you need.
Less code - less time - less errors...
(in northern germany they call this 'schlau schnacken' :)
--
cu,
Michael Andres
+------------------------------------------------------------------+
Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4
+------------------------------------------------------------------+
Michael Andres YaST Development ma@xxxxxxxxxx
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg)
Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0
+------------------------------------------------------------------+
--
To unsubscribe, e-mail: zypp-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-devel+help@xxxxxxxxxxxx
> USE RAII
> http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
>
> Resource Acquisition Is Initialization, often referred to by the acronym RAII,
> is a popular programming technique in C++ and D. The technique
> combines acquisition and release of resources with initialization and
> uninitialization of variables.
libzypp/doc/autodoc/html/group__g__RAII.html
(Icomplete like most docs ;( Fell free to add and update it. )
class zypp::DtorReset
Assign a vaiable a certain value when going out of scope
class zypp::base::Fd
Assert close called on open filedescriptor
struct zypp::str::SafeBuf
Assert free called for allocated char *
Some more examples, not (yet) listed:
zypp::AutoDispose< _Tp >
Reference counted access to a _Tp object calling a custom Dispose
function when the last AutoDispose handle to it is destroyed or reset.
Sounds more complicated than it actually is. See the
AutoDispose<const Pathname> example for exception safe
handling of temporary files.
Used eg. to return the binary rpm retrieved from some media.
Dependent on the type of media (downladed or not), and the
way it was retrieved, we need different kinds of
Of course: libzypp/doc/autodoc/html/group__ZYPP__SMART__PTR.html
zypp::filesystem::TmpFile
Provide a new empty temporary file and delete it when no longer
needed.
zypp::filesystem::TmpDir
Provide a new empty temporary directory and recursively delete it
when no longer needed.
None of these is complete or perfect. But we have at least some solutions
for some problems.
But they don't help if they are not used.
If you're looking for a solution and don't find it, ask for it. Maybe
something is there and you did not find it. If not, it's probabely
worth creating or improving something.
I know, more common solutions take a bit longer in the beginning. But
they soon outperform any copy-and-paste code.
Don't try to write as much code as you can. Only as much as you need.
Less code - less time - less errors...
(in northern germany they call this 'schlau schnacken' :)
--
cu,
Michael Andres
+------------------------------------------------------------------+
Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4
+------------------------------------------------------------------+
Michael Andres YaST Development ma@xxxxxxxxxx
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg)
Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0
+------------------------------------------------------------------+
--
To unsubscribe, e-mail: zypp-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-devel+help@xxxxxxxxxxxx
| < Previous | Next > |