interface

How to check at runtime if a class implements certain interface?

Let's say I have some content classes like Page, TabGroup, Tab, etc. Certain of those will be implementing my IWidgetContainer interface - it means they will geet an additional field named ContainedItems from the interface and some methods for manipulating this field. Now I need to reflect the fact that some class implements this interf...

Difference between implementing an interface and applying an attribute in C#

This might be a stupid question but Ill ask anyway, I was reading "OOP Demystified: A Self-Teaching Guide by Jim Keogh and Mario Giannini" chapter 11 which covers interfaces. The examples in this book are C++. I noticed that C++ uses ISerializable to make a class serializable which you would implement where as in C# you just attribute ...

JavaScript: Achieving precise animation end values?

I'm currently trying to write my own JavaScript library. I'm in the middle of writing an animation callback, but I'm having trouble getting precise end values, especially when animation duration times are smaller. Right now, I'm only targeting positional animation (left, top, right, bottom). When my animations complete, they end up hav...

Calling R Script from within C-Code

Hi, Is there a way to call an R-Script within C-Code? I did find the R Api for C (chaper 6. of the 'Writing R Extensions' manual), but as far as I understood this does "only" allow to call the C-Implementation of R. Of cause I could call the R-Script via shell, but that's no solution for me, since this does not allow proper passing of...

Polymorphic NHibernate mappings

I have an interface IUserLocation and a concrete type UserLocation. When I use ICriteria, specifying the interface IUserLocation, I want NHibernate to instantiate a collection of the concrete UserLocation type. I have created an HBM mapping file using the table per concrete type strategy (shown below). However, when I query NHibernate ...

Where should I put interface?

I program a class in which I have a method which takes an callback object from an external software. At the moment Eclipse says that it does not know the type of the object I gave as argument (it is expectable since I do not specify this type, it's done by the external software). So, I think I need to write an interface for the object w...

Interface helpers or delegating interface parent

If I have an existing IInterface descendant implemented by a third party, and I want to add helper routines, does Delphi provide any easy way to do so without redirecting every interface method manually? That is, given an interface like so: IFoo = interface procedure Foo1; procedure Foo2; ... procedure FooN; end; Is anything ...

Interface member name conflicts in ActionScript 3

I am trying to create an ActionScript 3 class that implements two interfaces. The interfaces contain member functions with different signatures but the same name: public interface IFoo { function doStuff(input:int):void; } public interface IBar { function doStuff(input1:String, input2:Number):void; } public class FooBar implem...

How to force my method to accept objects from external software?

I have a method which needs to take a callback object as an argument and then (at the moment when it's needed) my method will call a specific method of the callback object. I wrote a class called Manager which has a method called addListener. As the argument for this method I need to use a callback object which is defined by the externa...

Proper QUuid usage in Qt ? (7-Zip DLL usage problems (QLibrary, QUuid GUID conversion, interfaces))

Hi, I'm trying to write a program that would use 7-Zip DLL for reading files from inside archive files (7z, zip etc). Here's where I'm so far: #include QtCore/QCoreApplication #include QLibrary #include QUuid #include iostream using namespace std; #include "7z910/CPP/7zip/Archive/IArchive.h" #include "7z910/CPP/7zip/IStre...

Implementation/interface inheritance design question.

I would like to get the stackoverflow community's opinion on the following three design patterns. The first is implementation inheritance; the second is interface inheritance; the third is a middle ground. My specific question is: Which is best? implementation inheritance: class Base { X x() const = 0; void UpdateX(A a) { y_ = g(...

Interface in a dynamic language?

Interface (or an abstract class with all the methods abstract) is a powerful weapon in a static-typed language such as C#, JAVA. It allows different derived types to be used in a uniformed way. Design patterns encourage us to use interface as much as possible. However, in a dynamic-typed language, all objects are not checked for their t...

Is there a way to make sure classes implementing an Interface implement static methods?

First of all, I read erickson's useful reply to "Why can’t I define a static method in a Java interface?". This question is not about the "why" but about the "how then?". Edit: my original example was ill-posed, but I'll leave it bellow. While I am now convinced that in most cases what I want to do is overkill, there is one scenario wh...

Need to cast to an object without knowing what type the object is

I am trying to dynamically load my authentication server type based on a setting. I am hung up on how to cast to a type when I don't know the type. Type t = Type.GetType(WebConfigurationManager.AppSettings.Get("AuthenticationSvcImpl")); IAuthenticationService authCli = Activator.CreateInstance(t); return authCli.Authenticat...

Is it possible to use AutoMapper to wrap methods?

I have two classes: public class TestClass1 { public int TestInt { get; set; } public void TestMethod() { // Do something } } public class TestClass2 { public int TestInt { get; set; } public void TestMethod() { // Do something } } I want to create interface that I can use for both cl...

Determining image sizes for multiple android screen sizes/densities

I've been reviewing the Supporting Multiple Screens documentation on the Android and I just need some additional clarification... It's my understanding that designing three unique interfaces (ldpi, mdpi, and hdpi) would be the best way to go about supporting all the potential android screens with minimal scaling/distortion. Yes, I kno...

Qt, can't display child widget

I have two widgets defined as follows class mainWindow : public QWidget { Q_OBJECT public: mainWindow(); void readConfig(); private: SWindow *config; QVector <QString> filePath; QVector <QLabel*> alias,procStatus; QVector <int> delay; QGridLayout *mainLayout; QVector<QPushButton*> stopButton,restartBu...

Interface "not marked with serializable attribute" exception

I have a very odd exception in my C# app: when trying to deserialize a class containing a generic List<IListMember> (where list entries are specified by an interface), an exception is thrown reporting that "the type ...IListMember is not marked with the serializable attribute" (phrasing may be slightly different, my VisualStudio is not i...

What does an "interface extends interface" relationship look like in UML?

In Java it's perfectly legal for an interface to extend an interface. Does this relationship in UML look like an "extends" relationship (solid line, closed, unfilled arrowhead) or an "implements" relationship (dotted line, close, unfilled arrowhead)? I can't seem to find an example of this relationship either online or in Fowler's book. ...

c# How to implement a collection of generics

I have a worker class that does stuff with a collection of objects. I need each of those objects to have two properties, one has an unknown type and one has to be a number. I wanted to use an interface so that I could have multiple item classes that allowed for other properties but were forced to have the PropA and PropB that the worke...