namespace bife {
- using std::string;
-
/**
* Base Container Class.
*
using std::endl;
#endif
-Fallback::Fallback(const string& name): name(name) {
+Fallback::Fallback(void) {
#ifdef DEBUG
- cerr << "In Fallback::Fallback(name = '" << name << "');" << endl;
+ cerr << "In Fallback::Fallback();" << endl;
#endif
}
-Fallback::Fallback(const string& name, const Hash& attrs):
- Container(attrs), name(name) {
+Fallback::Fallback(const Hash& attrs): Container(attrs) {
#ifdef DEBUG
- cerr << "In Fallback::Fallback(name = '" << name
- << "', attrs = {" /* TODO << attrs */ << "});" << endl;
+ cerr << "In Fallback::Fallback(attrs = {" /* TODO << attrs */ << "});" << endl;
#endif
}
-Fallback::Fallback(const string& name, const Hash& attrs, Widget* content):
- Container(attrs, content), name(name) {
+Fallback::Fallback(const Hash& attrs, Widget* content): Container(attrs, content) {
// FIXME - this->content.push_back(content);
#ifdef DEBUG
- cerr << "In Fallback::Fallback(name = '" << name
- << "', attrs = {" /* TODO << attrs */
+ cerr << "In Fallback::Fallback(attrs = {" /* TODO << attrs */
<< "}, content = {" /* TODO << content */ << "});" << endl;
#endif
}
-Fallback::Fallback(const string& name, Widget* content, const Hash& attrs):
- Container(content, attrs), name(name) {
+Fallback::Fallback(Widget* content, const Hash& attrs): Container(content, attrs) {
// FIXME - this->content.push_back(content);
#ifdef DEBUG
- cerr << "In Fallback::Fallback(name = '" << name
- << "', content = {" /* TODO << content */
+ cerr << "In Fallback::Fallback(content = {" /* TODO << content */
<< "}, attrs = {" /* TODO << attrs */ << "});" << endl;
#endif
}
// Typedefs
public:
/// Fallback constructor function prototype.
- typedef Fallback* Constructor(const string&, const string&, const Hash&);
+ //typedef Fallback* Constructor(const string&, const string&, const Hash&);
// Attributes.
public:
*
* @param name Name of the widget.
*/
- Fallback(const string&);
+ Fallback(void);
/**
* Constructor.
* @param name Name of the widget.
* @param attrs Widget attributes.
*/
- Fallback(const string&, const Hash&);
+ Fallback(const Hash&);
/**
* Constructor.
* @param attrs Widget attributes.
* @param content Content of the widget.
*/
- Fallback(const string&, const Hash&, Widget*);
+ Fallback(const Hash&, Widget*);
/**
* Constructor.
* @param name Name of the widget.
* @param content Content of the widget.
*/
- Fallback(const string&, Widget*);
+ //Fallback(Widget*);
/**
* Constructor.
* @param content Content of the widget.
* @param attrs Widget attributes.
*/
- Fallback(const string&, Widget*, const Hash&);
+ Fallback(Widget*, const Hash&);
/**
* Destructor.
if (fbClass.empty()) {
throw string("Widget '") + name + "' not found and now using a fallback class.";
} else {
- stack.push(fbNew(fbClass, name, attrs));
+ Fallback* fb;
+ try {
+ fb = dynamic_cast<Fallback*>(fbNew(fbClass, attrs));
+ if (!fb) {
+ throw string("Fallback widget '") + fbClass + " not found!";
+ }
+ } catch (...) {
+ throw fbClass + " is not a Fallback Widget!";
+ }
+ fb->name = name;
+ stack.push(fb);
}
}
if (!dlh) {
throw string("No se puede cargar el plug-in: ") + dlerror();
}
- fbNew = (Fallback::Constructor*)dlsym(dlh, "fallback_constructor");
- fbDel = (Widget::Destructor*)dlsym(dlh, "widget_destructor");
+ fbNew = (Widget::Constructor*)dlsym(dlh, "bife_widget_constructor");
+ fbDel = (Widget::Destructor*)dlsym(dlh, "bife_widget_destructor");
if (!fbNew || !fbDel) {
throw string("No se puede cargar el creador del plug-in: ") + dlerror();
}
using std::endl;
#endif
-Translate::Translate(const string& name): Fallback(name) {
+Translate::Translate(void) {
#ifdef DEBUG
- cerr << "In Translate::Translate(name = '" << name << "');" << endl;
+ cerr << "In Translate::Translate();" << endl;
#endif
}
-Translate::Translate(const string& name, const Hash& attrs): Fallback(name, attrs) {
+Translate::Translate(const Hash& attrs): Fallback(attrs) {
#ifdef DEBUG
- cerr << "In Translate::Translate(name = '" << name
- << "', attrs = {" /* TODO << attrs */ << "});" << endl;
+ cerr << "In Translate::Translate(attrs = {" /* TODO << attrs */ << "});" << endl;
#endif
}
-Translate::Translate(const string& name, const Hash& attrs, Widget* content):
- Fallback(name, attrs, content) {
+Translate::Translate(const Hash& attrs, Widget* content): Fallback(attrs, content) {
// FIXME - this->content.push_back(content);
#ifdef DEBUG
- cerr << "In Translate::Translate(name = '" << name
- << "', attrs = {" /* TODO << attrs */
+ cerr << "In Translate::Translate(attrs = {" /* TODO << attrs */
<< "}, content = {" /* TODO << content */ << "});" << endl;
#endif
}
-Translate::Translate(const string& name, Widget* content, const Hash& attrs):
- Fallback(name, content, attrs) {
+Translate::Translate(Widget* content, const Hash& attrs): Fallback(content, attrs) {
// FIXME - this->content.push_back(content);
#ifdef DEBUG
- cerr << "In Translate::Translate(name = '" << name
- << "', content = {" /* TODO << content */
+ cerr << "In Translate::Translate(content = {" /* TODO << content */
<< "}, attrs = {" /* TODO << attrs */ << "});" << endl;
#endif
}
public:
/**
* Constructor.
- *
- * @param name Name of the widget.
*/
- Translate(const string&);
+ Translate(void);
/**
* Constructor.
*
- * @param name Name of the widget.
* @param attrs Widget attributes.
*/
- Translate(const string&, const Hash&);
+ Translate(const Hash&);
/**
* Constructor.
*
- * @param name Name of the widget.
* @param attrs Widget attributes.
* @param content Content of the widget.
*/
- Translate(const string&, const Hash&, Widget*);
+ Translate(const Hash&, Widget*);
/**
* Constructor.
*
- * @param name Name of the widget.
* @param content Content of the widget.
*/
- Translate(const string&, Widget*);
+ //Translate(Widget*);
/**
* Constructor.
*
- * @param name Name of the widget.
* @param content Content of the widget.
* @param attrs Widget attributes.
*/
- Translate(const string&, Widget*, const Hash&);
+ Translate(Widget*, const Hash&);
/**
* Destructor.
using std::string;
/**
- * Fallback constructor.
+ * Widget constructor.
*
- * @param classname Name of the class to construct.
- * @param widgetname Name of the widget to construct.
- * @param attrs Widget's attributes.
- * @return A new Fallback widget.
+ * @param name Name of the widget to construct.
+ * @param attrs Widget's attributes.
+ * @return A new Widget.
*/
extern "C"
-Fallback* fallback_constructor(const string& classname, const string& widgetname, const Hash& attrs) {
- string cn = classname;
+Widget* bife_widget_constructor(const string& name, const Hash& attrs) {
+ string cn = name;
std::transform(cn.begin(), cn.end(), cn.begin(), std::tolower);
if (cn == "translate") {
- return new Translate(widgetname, attrs);
+ return new Translate(attrs);
} else {
return NULL;
}
* @param w The widget to destroy.
*/
extern "C"
-void widget_destructor(Widget* w) {
+void bife_widget_destructor(Widget* w) {
delete w;
}