summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2009-03-15 16:06:29 +0100
committerDennis kasprzyk <onestone@compiz-fusion.org>2009-03-15 16:06:29 +0100
commitf8cf2bc2d5a7fe2d4f90f217aa1b7f6e2d47c345 (patch)
tree38d61b9e1a4a3f447f47475e46ea2b17ae3dcd69
parentcb423b48a53ae10fd401d32a28c3e365a70b3b7e (diff)
downloadzcomp-f8cf2bc2d5a7fe2d4f90f217aa1b7f6e2d47c345.tar.gz
zcomp-f8cf2bc2d5a7fe2d4f90f217aa1b7f6e2d47c345.tar.bz2
Added base class for get/setOption(s) functions.
-rw-r--r--include/core/option.h10
-rw-r--r--include/core/screen.h10
-rw-r--r--src/option.cpp7
-rw-r--r--src/screen.cpp11
4 files changed, 23 insertions, 15 deletions
diff --git a/include/core/option.h b/include/core/option.h
index d058755..a67744b 100644
--- a/include/core/option.h
+++ b/include/core/option.h
@@ -140,6 +140,16 @@ class CompOption {
typedef std::vector<CompOption> Vector;
+ class Class {
+ public:
+ virtual Vector & getOptions () const = 0;
+
+ virtual CompOption * getOption (const CompString &name) const;
+
+ virtual bool setOption (const CompString &name,
+ Value &value) = 0;
+ };
+
public:
CompOption ();
CompOption (const CompOption &);
diff --git a/include/core/screen.h b/include/core/screen.h
index 29467d2..93a0d9c 100644
--- a/include/core/screen.h
+++ b/include/core/screen.h
@@ -127,7 +127,8 @@ class ScreenInterface : public WrapableInterface<CompScreen, ScreenInterface> {
class CompScreen :
public CompSize,
public WrapableHandler<ScreenInterface, 17>,
- public PluginClassStorage
+ public PluginClassStorage,
+ public CompOption::Class
{
public:
@@ -162,12 +163,9 @@ class CompScreen :
Display * dpy();
- CompOption::Vector & getOptions ();
-
- CompOption * getOption (const char *);
+ CompOption::Vector & getOptions () const;
- bool setOption (const char *name,
- CompOption::Value &value);
+ bool setOption (const CompString &name, CompOption::Value &value);
bool XRandr ();
diff --git a/src/option.cpp b/src/option.cpp
index 0140812..d90fbfc 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -582,6 +582,13 @@ CompOption::Restriction::operator= (const CompOption::Restriction &rest)
}
CompOption *
+CompOption::Class::getOption (const CompString &name) const
+{
+ CompOption *o = CompOption::findOption (getOptions (), name);
+ return o;
+}
+
+CompOption *
CompOption::findOption (CompOption::Vector &options,
CompString name,
unsigned int *index)
diff --git a/src/screen.cpp b/src/screen.cpp
index e4c0f07..9090ddb 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -625,13 +625,6 @@ CompScreen::dpy ()
return priv->dpy;
}
-CompOption *
-CompScreen::getOption (const char *name)
-{
- CompOption *o = CompOption::findOption (priv->opt, name);
- return o;
-}
-
bool
CompScreen::XRandr ()
{
@@ -744,13 +737,13 @@ PrivateScreen::handlePingTimeout ()
}
CompOption::Vector &
-CompScreen::getOptions ()
+CompScreen::getOptions () const
{
return priv->opt;
}
bool
-CompScreen::setOption (const char *name,
+CompScreen::setOption (const CompString &name,
CompOption::Value &value)
{
CompOption *o;