[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwin
Subject:    Review Request: Use templates in KWin::Rules
From:       Martin_Gräßlin <kde () martin-graesslin ! com>
Date:       2012-04-26 19:27:07
Message-ID: 20120426192707.15792.7565 () vidsolbach ! de
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/104744/
-----------------------------------------------------------

Review request for kwin.


Description
-------

Today's topic: fun with templates :-) I wanted to play with C++11 features =
but it ended as playing with templates.

Overall I think the code is a little bit better to read and could be furthe=
r improved with a few lambda methods.

As a nice side-effect of this change: no more warnings when compiling rules=
.cpp.

----
Commits:

Remove unused apply methods

All replaced by templated version.

Replace CHECK_(FORCE)_RULE with a templated method

For all the checkFoo methods a generic templated
implementation is added which is called by the
specific method.

Templated apply rule method

All applyFoo methods created by the APPLY_RULE
and APPLY_FORCE_RULE define call a templated
apply method.

To make this working a templated checkRule and
checkStop are added which delegate to
checkForceRule, checkSetRule, checkForceStop
and checkSetStop based on a template parameter.

The values and rules are resolved by fully
specialised templated methods functioning as
getters.

Turn discard rule into a templated method


Turn NOW_REMEMBER into a templated method


Use templated methods to read/write rules

Replaces c-defines by template methods.


Diffs
-----

  kwin/rules.h b66501c2c1ab3222815d58ec590a653271f7c1ad =

  kwin/rules.cpp 95c2d0b415c80daa01402167fdcc6643f7b30200 =


Diff: http://git.reviewboard.kde.org/r/104744/diff/


Testing
-------

It compiles (gcc, clang) :-) As Rules are a nice small unit I inted to writ=
e unit tests for all methods and by that ensure that the code did not break=
 with this change. That's why I added 4.10  - too late for 4.9.


Thanks,

Martin Gr=C3=A4=C3=9Flin


[Attachment #5 (text/html)]

<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;">  <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/104744/">http://git.reviewboard.kde.org/r/104744/</a>
  </td>
    </tr>
   </table>
   <br />


<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;">  <tr>
  <td>

<div>Review request for kwin.</div>
<div>By Martin Gräßlin.</div>







<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">Today&#39;s topic: fun with templates :-) I wanted to play with C++11 \
features but it ended as playing with templates.

Overall I think the code is a little bit better to read and could be further improved \
with a few lambda methods.

As a nice side-effect of this change: no more warnings when compiling rules.cpp.

----
Commits:

Remove unused apply methods

All replaced by templated version.

Replace CHECK_(FORCE)_RULE with a templated method

For all the checkFoo methods a generic templated
implementation is added which is called by the
specific method.

Templated apply rule method

All applyFoo methods created by the APPLY_RULE
and APPLY_FORCE_RULE define call a templated
apply method.

To make this working a templated checkRule and
checkStop are added which delegate to
checkForceRule, checkSetRule, checkForceStop
and checkSetStop based on a template parameter.

The values and rules are resolved by fully
specialised templated methods functioning as
getters.

Turn discard rule into a templated method


Turn NOW_REMEMBER into a templated method


Use templated methods to read/write rules

Replaces c-defines by template methods.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">It compiles (gcc, clang) :-) As Rules are a nice small unit I inted to \
write unit tests for all methods and by that ensure that the code did not break with \
this change. That&#39;s why I added 4.10  - too late for 4.9.</pre>  </td>
 </tr>
</table>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>kwin/rules.h <span style="color: \
grey">(b66501c2c1ab3222815d58ec590a653271f7c1ad)</span></li>

 <li>kwin/rules.cpp <span style="color: \
grey">(95c2d0b415c80daa01402167fdcc6643f7b30200)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/104744/diff/" style="margin-left: \
3em;">View Diff</a></p>




  </td>
 </tr>
</table>




  </div>
 </body>
</html>



_______________________________________________
kwin mailing list
kwin@kde.org
https://mail.kde.org/mailman/listinfo/kwin


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic