Search Results

Search found 8634 results on 346 pages for 'base'.

Page 3/346 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Creating a dynamic proxy generator with c# – Part 4 – Calling the base method

    - by SeanMcAlinden
    Creating a dynamic proxy generator with c# – Part 1 – Creating the Assembly builder, Module builder and caching mechanism Creating a dynamic proxy generator with c# – Part 2 – Interceptor Design Creating a dynamic proxy generator with c# – Part 3 – Creating the constructors   The plan for calling the base methods from the proxy is to create a private method for each overridden proxy method, this will allow the proxy to use a delegate to simply invoke the private method when required. Quite a few helper classes have been created to make this possible so as usual I would suggest download or viewing the code at http://rapidioc.codeplex.com/. In this post I’m just going to cover the main points for when creating methods. Getting the methods to override The first two notable methods are for getting the methods. private static MethodInfo[] GetMethodsToOverride<TBase>() where TBase : class {     return typeof(TBase).GetMethods().Where(x =>         !methodsToIgnore.Contains(x.Name) &&                              (x.Attributes & MethodAttributes.Final) == 0)         .ToArray(); } private static StringCollection GetMethodsToIgnore() {     return new StringCollection()     {         "ToString",         "GetHashCode",         "Equals",         "GetType"     }; } The GetMethodsToIgnore method string collection contains an array of methods that I don’t want to override. In the GetMethodsToOverride method, you’ll notice a binary AND which is basically saying not to include any methods marked final i.e. not virtual. Creating the MethodInfo for calling the base method This method should hopefully be fairly easy to follow, it’s only function is to create a MethodInfo which points to the correct base method, and with the correct parameters. private static MethodInfo CreateCallBaseMethodInfo<TBase>(MethodInfo method) where TBase : class {     Type[] baseMethodParameterTypes = ParameterHelper.GetParameterTypes(method, method.GetParameters());       return typeof(TBase).GetMethod(        method.Name,        BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,        null,        baseMethodParameterTypes,        null     ); }   /// <summary> /// Get the parameter types. /// </summary> /// <param name="method">The method.</param> /// <param name="parameters">The parameters.</param> public static Type[] GetParameterTypes(MethodInfo method, ParameterInfo[] parameters) {     Type[] parameterTypesList = Type.EmptyTypes;       if (parameters.Length > 0)     {         parameterTypesList = CreateParametersList(parameters);     }     return parameterTypesList; }   Creating the new private methods for calling the base method The following method outline how I’ve created the private methods for calling the base class method. private static MethodBuilder CreateCallBaseMethodBuilder(TypeBuilder typeBuilder, MethodInfo method) {     string callBaseSuffix = "GetBaseMethod";       if (method.IsGenericMethod || method.IsGenericMethodDefinition)     {                         return MethodHelper.SetUpGenericMethod             (                 typeBuilder,                 method,                 method.Name + callBaseSuffix,                 MethodAttributes.Private | MethodAttributes.HideBySig             );     }     else     {         return MethodHelper.SetupNonGenericMethod             (                 typeBuilder,                 method,                 method.Name + callBaseSuffix,                 MethodAttributes.Private | MethodAttributes.HideBySig             );     } } The CreateCallBaseMethodBuilder is the entry point method for creating the call base method. I’ve added a suffix to the base classes method name to keep it unique. Non Generic Methods Creating a non generic method is fairly simple public static MethodBuilder SetupNonGenericMethod(     TypeBuilder typeBuilder,     MethodInfo method,     string methodName,     MethodAttributes methodAttributes) {     ParameterInfo[] parameters = method.GetParameters();       Type[] parameterTypes = ParameterHelper.GetParameterTypes(method, parameters);       Type returnType = method.ReturnType;       MethodBuilder methodBuilder = CreateMethodBuilder         (             typeBuilder,             method,             methodName,             methodAttributes,             parameterTypes,             returnType         );       ParameterHelper.SetUpParameters(parameterTypes, parameters, methodBuilder);       return methodBuilder; }   private static MethodBuilder CreateMethodBuilder (     TypeBuilder typeBuilder,     MethodInfo method,     string methodName,     MethodAttributes methodAttributes,     Type[] parameterTypes,     Type returnType ) { MethodBuilder methodBuilder = typeBuilder.DefineMethod(methodName, methodAttributes, returnType, parameterTypes); return methodBuilder; } As you can see, you simply have to declare a method builder, get the parameter types, and set the method attributes you want.   Generic Methods Creating generic methods takes a little bit more work. /// <summary> /// Sets up generic method. /// </summary> /// <param name="typeBuilder">The type builder.</param> /// <param name="method">The method.</param> /// <param name="methodName">Name of the method.</param> /// <param name="methodAttributes">The method attributes.</param> public static MethodBuilder SetUpGenericMethod     (         TypeBuilder typeBuilder,         MethodInfo method,         string methodName,         MethodAttributes methodAttributes     ) {     ParameterInfo[] parameters = method.GetParameters();       Type[] parameterTypes = ParameterHelper.GetParameterTypes(method, parameters);       MethodBuilder methodBuilder = typeBuilder.DefineMethod(methodName,         methodAttributes);       Type[] genericArguments = method.GetGenericArguments();       GenericTypeParameterBuilder[] genericTypeParameters =         GetGenericTypeParameters(methodBuilder, genericArguments);       ParameterHelper.SetUpParameterConstraints(parameterTypes, genericTypeParameters);       SetUpReturnType(method, methodBuilder, genericTypeParameters);       if (method.IsGenericMethod)     {         methodBuilder.MakeGenericMethod(genericArguments);     }       ParameterHelper.SetUpParameters(parameterTypes, parameters, methodBuilder);       return methodBuilder; }   private static GenericTypeParameterBuilder[] GetGenericTypeParameters     (         MethodBuilder methodBuilder,         Type[] genericArguments     ) {     return methodBuilder.DefineGenericParameters(GenericsHelper.GetArgumentNames(genericArguments)); }   private static void SetUpReturnType(MethodInfo method, MethodBuilder methodBuilder, GenericTypeParameterBuilder[] genericTypeParameters) {     if (method.IsGenericMethodDefinition)     {         SetUpGenericDefinitionReturnType(method, methodBuilder, genericTypeParameters);     }     else     {         methodBuilder.SetReturnType(method.ReturnType);     } }   private static void SetUpGenericDefinitionReturnType(MethodInfo method, MethodBuilder methodBuilder, GenericTypeParameterBuilder[] genericTypeParameters) {     if (method.ReturnType == null)     {         methodBuilder.SetReturnType(typeof(void));     }     else if (method.ReturnType.IsGenericType)     {         methodBuilder.SetReturnType(genericTypeParameters.Where             (x => x.Name == method.ReturnType.Name).First());     }     else     {         methodBuilder.SetReturnType(method.ReturnType);     }             } Ok, there are a few helper methods missing, basically there is way to much code to put in this post, take a look at the code at http://rapidioc.codeplex.com/ to follow it through completely. Basically though, when dealing with generics there is extra work to do in terms of getting the generic argument types setting up any generic parameter constraints setting up the return type setting up the method as a generic All of the information is easy to get via reflection from the MethodInfo.   Emitting the new private method Emitting the new private method is relatively simple as it’s only function is calling the base method and returning a result if the return type is not void. ILGenerator il = privateMethodBuilder.GetILGenerator();   EmitCallBaseMethod(method, callBaseMethod, il);   private static void EmitCallBaseMethod(MethodInfo method, MethodInfo callBaseMethod, ILGenerator il) {     int privateParameterCount = method.GetParameters().Length;       il.Emit(OpCodes.Ldarg_0);       if (privateParameterCount > 0)     {         for (int arg = 0; arg < privateParameterCount; arg++)         {             il.Emit(OpCodes.Ldarg_S, arg + 1);         }     }       il.Emit(OpCodes.Call, callBaseMethod);       il.Emit(OpCodes.Ret); } So in the main method building method, an ILGenerator is created from the method builder. The ILGenerator performs the following actions: Load the class (this) onto the stack using the hidden argument Ldarg_0. Create an argument on the stack for each of the method parameters (starting at 1 because 0 is the hidden argument) Call the base method using the Opcodes.Call code and the MethodInfo we created earlier. Call return on the method   Conclusion Now we have the private methods prepared for calling the base method, we have reached the last of the relatively easy part of the proxy building. Hopefully, it hasn’t been too hard to follow so far, there is a lot of code so I haven’t been able to post it all so please check it out at http://rapidioc.codeplex.com/. The next section should be up fairly soon, it’s going to cover creating the delegates for calling the private methods created in this post.   Kind Regards, Sean.

    Read the article

  • How Can I Install LibreOffice Base?

    - by Rob
    Useful info: I have tried running sudo dpkg --configure -a and sudo apt-get install -f with no result. I am running Kubuntu 11.10 (the updater is far too unreliable to ever be trusted with performing a version upgrade) The rest of LibreOffice seems to work fine (apart from an annoying bug where tooltips are shown as black text on black background...) I have need to use LibreOffice Base to complete a mail merge document. However, I noticed it's not installed. When I go to install it however... rob@hydrogen:~$ sudo apt-get install libreoffice-base [sudo] password for rob: Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies. libreoffice-base : Depends: libreoffice-core (= 1:3.4.4-0ubuntu1) but it is not going to be installed Depends: libreoffice-base-core (= 1:3.4.4-0ubuntu1) but it is not going to be installed Depends: libreoffice-java-common (>= 1:3.4.4~) but it is not going to be installed Suggests: libmyodbc but it is not going to be installed or odbc-postgresql but it is not going to be installed or libsqliteodbc but it is not going to be installed or tdsodbc but it is not going to be installed or mdbtools but it is not going to be installed Suggests: libreoffice-gcj but it is not installable Suggests: libreoffice-report-builder but it is not going to be installed E: Unable to correct problems, you have held broken packages. I'm bemused as to which packages it seems to think I have held. As far as I'm aware, Kubuntu doesn't give you the option to hold packages... So, how do I get out of this dependency hell?

    Read the article

  • Missing ODBCConfig for SQLite and LibreOffice Base

    - by MikeD
    I have used OpenOffice Base as a front end for SQlite databases, in 10.04 linked via ODBC. I am updating to 12.04, so I loaded LibreOffice Base, looks just like OObase. I have 12.04 on one drive and 10.04 on another. I loaded Sqliteman, sqlite3, unixodbc-bin, unixodbc, libsqliteodbc, sqlitebrowser. I copied my databases directory over. But in terminal ODBCConfig is not on the 12.04 system. So I copied odbc.ini from the home directory on 10.04 to 12.04 home directory, and now LibreOffice Base can access my database, and all is fine. Anyone know what is the problem with ODBCConfig, is it another victim of the change in QT? Of course I could edit odbc.ini with jedit, now I can see the format. In terminal I tried sudo find / -name ODBCConfig, but its not there.

    Read the article

  • Generate canonical / real URL based on base.href or location

    - by blueyed
    Is there a method/function to get the canonical / transformed URL, respecting any base.href setting of the page? I can get the base URL via (in jQuery) using $("base").attr("href") and I could use string methods to parse the URL meant to being made relative to this, but $("base").attr("href") has no host, path etc attributes (like window.location has) manually putting this together is rather tedious E.g., given a base.href of "http://example.com/foo/" and a relative URL "/bar.js", the result should be: "http://example.com/bar.js" If base.href is not present, the URL should be made relative to window.location. This should handle non-existing base.href (using location as base in this case). Is there a standard method available for this already? (I'm looking for this, since jQuery.getScript fails when using a relative URL like "/foo.js" and BASE tag is being used (FF3.6 makes an OPTIONS request, and nginx cannot handle this). When using the full URL (base.href.host + "/foo.js", it works).)

    Read the article

  • Calling base class constructor

    - by The Void
    In the program below, is the line Derived(double y): Base(), y_(y) correct/allowed? That is, does it follow ANSI rules? #include <iostream> class Base { public: Base(): x_(0) { std::cout << "Base default constructor called" << std::endl; } Base(int x): x_(x) { std::cout << "Base constructor called with x = " << x << std::endl; } void display() const { std::cout << x_ << std::endl; } protected: int x_; }; class Derived: public Base { public: Derived(): Base(1), y_(1.2) { std::cout << "Derived default constructor called" << std::endl; } Derived(double y): Base(), y_(y) { std::cout << "Derived constructor called with y = " << y << std::endl; } void display() const { std::cout << Base::x_ << ", " << y_ << std::endl; } private: double y_; }; int main() { Base b1; b1.display(); Derived d1; d1.display(); std::cout << std::endl; Base b2(-9); b2.display(); Derived d2(-8.7); d2.display(); return 0; }

    Read the article

  • What really is the purpose of "base" keyword in c#?

    - by Pandiya Chendur
    Thus for used base class for some commom reusable methods in every page of my application... public class BaseClass:System.Web.UI.Page { public string GetRandomPasswordUsingGUID(int length) { string guidResult = System.Guid.NewGuid().ToString(); guidResult = guidResult.Replace("-", string.Empty); return guidResult.Substring(0, length); } } So if i want to use this method i would just do, public partial class forms_age_group : BaseClass { protected void Page_Load(object sender, EventArgs e) { //i would just call it like this string pass = GetRandomPasswordUsingGUID(10); } } It does what i want but there is a "Base" keyword that deals with base class in c# ... I really want to know when should use base keyword in my derived class.... Any good example...

    Read the article

  • How to override <base> tag without removing the tag itself?

    - by sSmacKk
    I'm trying to add some internal links(in the format of a content table, to be able to facilitate webpage navigation) to this site in which a tag is used. Now obviously due to the base tag, every other relative tag will be relative to the base tag href. But in order for me to create this internal content table with the links pointing to different parts of the specific page, i need to get the default URL (before base tag is in effect) so the internal links can work properly. Is there a way to do get around the base tag and accomplish this? PS: if the question is unclear please don't hesitate to ask so i can reformulate Thanks in advance, :D :D

    Read the article

  • Internet is not working in base machine

    - by surendar
    I have a Ubuntu desktop. I am running a virtual windows machine using virtual box. Few days before Internet is not working in Ubuntu but it is working in the virtual machine. Even the samba shares are also accessible. I don't know why internet is not working in the base machine. I have tried to ping google.com, but it returns Ubuntu@desktop:~$ ping google.com ping: unknown host google.com ifconfig command's output Ubuntu@desktop:~$ ifconfig eth0 Link encap:Ethernet HWaddr 00:27:0e:1b:86:2a inet addr:192.168.1.7 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::227:eff:fe1b:862a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:38221 errors:0 dropped:0 overruns:0 frame:0 TX packets:28161 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:39144616 (39.1 MB) TX bytes:6143919 (6.1 MB) Interrupt:27 Base address:0x2000 eth0:0 Link encap:Ethernet HWaddr 00:27:0e:1b:86:2a inet addr:192.168.2.7 Bcast:192.168.2.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:27 Base address:0x2000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:14944 errors:0 dropped:0 overruns:0 frame:0 TX packets:14944 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1735451 (1.7 MB) TX bytes:1735451 (1.7 MB) vmnet1 Link encap:Ethernet HWaddr 00:50:56:c0:00:01 inet addr:192.168.243.1 Bcast:192.168.243.255 Mask:255.255.255.0 inet6 addr: fe80::250:56ff:fec0:1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:77 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) vmnet8 Link encap:Ethernet HWaddr 00:50:56:c0:00:08 inet addr:172.16.162.1 Bcast:172.16.162.255 Mask:255.255.255.0 inet6 addr: fe80::250:56ff:fec0:8/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:78 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

    Read the article

  • Web Applications Desktop Integrator (WebADI) Feature for Install Base Mass Update in 12.1.3

    - by LuciaC
    Purpose The integration of WebADI technology with the Install Base Mass Update function is designed to make creation and update of bulk item instances much easier than in the past. What is it? WebADI is an Excel-based desktop application where users can download an Excel template with item instances pre-populated based on search criteria.  Users can create and update item instances in the Excel sheet and finally upload the Excel data using an "upload" option available in the Excel menu. On upload, the modified data will bulk upload to interface tables which are processed by an asynchronous concurrent program that users can monitor for the uploaded results. Advantage: This allows users to work in a disconnected Environment: session time outs can be avoided, as once a template is downloaded the user can work in a disconnected environment and once all updates are done the new input can be uploaded. Also the data can be saved for later update and upload. For more details review the following: R12.1.3 Install Base WebADI Mass Update Feature (Doc ID 1535936.1) How To Use Install Base WebADI Mass Update Feature In Release 12.1.3 (Doc ID 1536498.1).

    Read the article

  • Accessing constructor from abstract base class with reflection

    - by craesh
    Hi! I'm playing around with Java's Reflection. I have an abstract class Base with a constructor. abstract class Base { public Base( String foo ) { // do some magic } } I have some further classes extending Base. They don't contain much logic. I want to instantiate them with Base's constructor, without having to write some proxy contructors in those derived classes. And of course, I want to instantiate those derived classes with Reflection. Say: Class cls = SomeDerivedClass.class; Constructor constr; constr = cls.getConstructor( new Class[] { String.class } ); // will return null Class clsBase = Base.class; constr = clsBase.getConstructor( new Class[] { String.class } ); // ok Base obj = (Base) constr.newInstance( new Object[] { "foo" } ); // will throw InstantiationException because it belongs to an abstract class Any ideas, how I can instantiate a derived class with Base's constructor? Or must I declare those dumb proxy constructors?

    Read the article

  • How to avoid "incomplete implementation" warning in partial base class

    - by garph0
    I have created a protocol that my classes need to implement, and then factored out some common functionality into a base class, so I did this: @protocol MyProtocol - (void) foo; - (void) bar; @end @interface Base <MyProtocol> @end @interface Derived_1 : Base @end @interface Derived_2 : Base @end @implementation Base - (void) foo{ //something foo } @end @implementation Derived_1 - (void) bar{ //something bar 1 } @end @implementation Derived_2 - (void) bar{ //something bar 2 } @end In this way in my code I use a generic id<MyProtocol>. The code works (as long as Base is not used directly) but the compiler chokes at the end of the implementation of Base with a warning: Incomplete implementation of class Base Is there a way to avoid this warning or, even better, a more proper way to obtain this partially implemented abstract base class behavior in Objc?

    Read the article

  • Getting a 'base' Domain from a Domain

    - by Rick Strahl
    Here's a simple one: How do you reliably get the base domain from full domain name or URI? Specifically I've run into this scenario in a few recent applications when creating the Forms Auth Cookie in my ASP.NET applications where I explicitly need to force the domain name to the common base domain. So, www.west-wind.com, store.west-wind.com, west-wind.com, dev.west-wind.com all should return west-wind.com. Here's the code where I need to use this type of logic for issuing an AuthTicket explicitly:private void IssueAuthTicket(UserState userState, bool rememberMe) { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userState.UserId, DateTime.Now, DateTime.Now.AddDays(10), rememberMe, userState.ToString()); string ticketString = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, ticketString); cookie.HttpOnly = true; if (rememberMe) cookie.Expires = DateTime.Now.AddDays(10); // write out a domain cookie cookie.Domain = Request.Url.GetBaseDomain(); HttpContext.Response.Cookies.Add(cookie); } Now unfortunately there's no Uri.GetBaseDomain() method unfortunately, as I was surprised to find out. So I ended up creating one:public static class NetworkUtils { /// <summary> /// Retrieves a base domain name from a full domain name. /// For example: www.west-wind.com produces west-wind.com /// </summary> /// <param name="domainName">Dns Domain name as a string</param> /// <returns></returns> public static string GetBaseDomain(string domainName) { var tokens = domainName.Split('.'); // only split 3 segments like www.west-wind.com if (tokens == null || tokens.Length != 3) return domainName; var tok = new List<string>(tokens); var remove = tokens.Length - 2; tok.RemoveRange(0, remove); return tok[0] + "." + tok[1]; ; } /// <summary> /// Returns the base domain from a domain name /// Example: http://www.west-wind.com returns west-wind.com /// </summary> /// <param name="uri"></param> /// <returns></returns> public static string GetBaseDomain(this Uri uri) { if (uri.HostNameType == UriHostNameType.Dns) return GetBaseDomain(uri.DnsSafeHost); return uri.Host; } } I've had a need for this so frequently it warranted a couple of helpers. The second Uri helper is an Extension method to the Uri class, which is what's used the in the first code sample. This is the preferred way to call this since the URI class can differentiate between Dns names and IP Addresses. If you use the first string based version there's a little more guessing going on if a URL is an IP Address. There are a couple of small twists in dealing with 'domain names'. When passing a string only there's a possibility to not actually pass domain name, but end up passing an IP address, so the code explicitly checks for three domain segments (can there be more than 3?). IP4 Addresses have 4 and IP6 have none so they'll fall through. Then there are things like localhost or a NetBios machine name which also come back on URL strings, but also shouldn't be handled. Anyway, small thing but maybe somebody else will find this useful.© Rick Strahl, West Wind Technologies, 2005-2012Posted in ASP.NET  Networking   Tweet !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs"); (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })();

    Read the article

  • Cheetah with Cherrypy: how to load base templates, and do so automatically on change during developm

    - by Heikki Toivonen
    I am working on a cherrypy+cheetah app and would like to improve the development experience. I have everything working when I manually compile templates beforehand. However, during development I'd rather just load the templates every time they are referenced so that I don't need to kill and restart my application. I have a couple of issues I am facing: If I have templates inheriting from base templates, I get import errors (can't find base templates). I think I had this actually working during my experiments, but unfortunately didn't save it and now I can't make it work. Suppose I get 1. working, how do make it so that edits even in base templates get picked up without restart. Below is my sample application that should demonstrate the problems. The directory structure is as follows: t.py templates/ base.tmpl index.tmpl t.py: import sys import cherrypy from Cheetah.Template import Template class T: def __init__(self, foo): self.foo = foo @cherrypy.expose def index(self): return Template(file='templates/index.tmpl', searchList=[{'foo': self.foo}]).respond() cherrypy.quickstart(T(sys.argv[1])) base.tmpl: #def body This is the body from the base #end def This is the base doc index.tmpl: #from templates.base import base #extends base #def body $base.body(self) This is the extended body #end def This is from index Run it like this: python t.py Something

    Read the article

  • error: 'void Base::output()' is protected within this context

    - by Bill
    I'm confused about the errors generated by the following code. In Derived::doStuff, I can access Base::output directly by calling it. Why can't I create a pointer to output() in the same context that I can call output()? (I thought protected / private governed whether you could use a name in a specific context, but apparently that is incomplete?) Is my fix of writing callback(this, &Derived::output); instead of callback(this, Base::output) the correct solution? #include <iostream> using std::cout; using std::endl; template <typename T, typename U> void callback(T obj, U func) { ((obj)->*(func))(); } class Base { protected: void output() { cout << "Base::output" << endl; } }; class Derived : public Base { public: void doStuff() { // call it directly: output(); Base::output(); // create a pointer to it: // void (Base::*basePointer)() = &Base::output; // error: 'void Base::output()' is protected within this context void (Derived::*derivedPointer)() = &Derived::output; // call a function passing the pointer: // callback(this, &Base::output); // error: 'void Base::output()' is protected within this context callback(this, &Derived::output); } }; int main() { Derived d; d.doStuff(); }

    Read the article

  • Learning the base for programming in C

    - by Baltazar Blake
    it's been a while since I think about starting to programming in C and after that to learn programming in C# and I search a lot on google but couldn't find a good guide to start learning base programming in C .However I found that Eclipe integrates very good with Ubuntu and it's a good programming environment for starting to program in C but somebody can give please some links with guides or tell me where can I find the bases for starting to program in C ,and I mean good base because I found a lot of incomplete guides over google ? And if I don't ask to much please give some tips of how to start and how to use Eclipse.Every help will be welcome ,thanks.

    Read the article

  • Easiest turn-base games you can think of?

    - by Edgar Miranda
    I'm planning to get into the process of programming multiplayer turn-base games. I would like to start off by making some of the simplest (yet fun) multiplayer turn-base games out there. What are some that you can provide? For example... Tic-Tac-Toe Rock-Paper-Scissors Checkers Some not so easy games... 4 in a row chess poker In terms of "ease" of implementation I'm mainly looking at logic. For example, Rock-Paper-Scissors has very simple logic, while chess has logic that is more complicated. So far I have the following: Hexagon Heroes of Might and Magic Nine Men's Morris Connect 4 21 (card game) Pen the Pig (The Dot game) Memory Match

    Read the article

  • Base Pages and Interfaces for ASP.NET Pages

    - by geekrutherford
    For quite a while I have been using the concept of base pages when developing pages in ASP.NET applications. It is a wonderful method for exposing common functions to all of your applications pages and also overriding certain events for various purposes (i.e. dynamic themes).  Recently I found out a new developer will be joining my team. This prompted me to review the applications code for readability and ease of maintenance. I began adding comments through out the code behind for all pages within the application. While doing so I noted that I had used common method names for such things as loading data, configuring controls, applying filters, etc.   Bringing a new developer on board, I wanted to make the transition as seamless as possible while also ensuring they follow existing coding practices we already have in place. While I could have created virtual methods for the common page methods allowing them to overridden, what I really needed was a way to ensure the new developer implemented the same methods for each and every page. Thus I created an interface to force the issue.   Now, every page not only inherits the base page class but also implements an interface. This provides every page not only common functions and overridden page events but also imposes rules for implementing certain common methods :-)   Interface   public interface BasePageInterface { /// Configures page based on users security permissions. void CheckPermissions(); /// Configures Filter Form control for current page.  /// Ensure you have set the FilteredGrid and PageAjaxManager properties of the FilterForm control in PageLoad!!!  void ConfigureFilters(); /// Sets event handlers and default settings for controls on the current page. void ConfigureControls(); /// Exports data bound to grid in selected format. void ExportGridData(ExportFormat fmt); /// Loads data and binds to grid. /// Columns are turned on/off in grid depending on tab selected and users permissions.  void LoadData(); }   Page code-behind class definition:   public partial class MyPage : BasePage, BasePageInterface Note, you could not use an abstract class to accomplish this considering C# does not allow for multiple inheritance.  Nor could the base page class be abstract since it needs to inherit from the System.Web.UI.Page class in order to override page events.

    Read the article

  • Introduction à JPA, application au chargement de données depuis une base MySQL, par Thierry Leriche-Dessirier

    Bonjour à tous, Je vous propose un nouvel article rapide, intitulé "Introduction à JPA, application au chargement de données depuis une base MySQL" et disponible à l'adresse suivante : http://thierry-leriche-dessirier.dev...sql-jpa-intro/ Ce miniarticle montre (par l'exemple) comment charger des données depuis une base MySQL, à l'aide de JPA (Java Persistence API), en quelques minutes et en nous limitant aux fonctionnalités simples. Attention : La techno JPA (Java Persistence API) est relativement complexe. Dans cet article, nous n'abordons que les points faciles. Ceci n'est donc pas un tutoriel complet m...

    Read the article

  • overriding implemented base class methods

    - by user793468
    I read somewhere that the chain of inheritance breaks when you alter a behavior from derived class. What does "altering a behavior" mean here? Is overriding an already implemented method in base class considered as "altering behavior"? Or, does the author mean altering method signatures and the output? Also, I ready Duplicating code is not a good practice, and its a maintenance nightmare. Again, does overriding an already implemented method in base class considered "Duplicating code"? If not, what would be considered as "Duplicating code"? I

    Read the article

  • Création du forum XQUERY et base de données XML, dédié aux utilisations de XML comme base de données ou avec des SGBD relationnels

    Création d'un forum XQUERY et base de donnée XML dédié aux utilisation de XML en tant que base de donnée ou avec des SGBD relationnels Le développement du format XML, en particulier dans un contexte d'utilisation documentaire (Ooo, word...) mais aussi d'échange de donnée, dut à la complexification de ces mêmes données, a amené à une interaction accrue entre les fichiers XML et les SGBD. Différentes types de solutions ont vues le jour :ensemble de fichier XML intégration dans des SGBD relationnels SGBD XML natif ... Et différents langages d'extraction/constitution pour utiliser ces même données , en fonction de l'environnement...

    Read the article

  • C# Hiding, overriding and calling function from base class.

    - by Lukasz Lysik
    I'm learning C# and I encountered the following problem. I have two classes: base and derived: class MyBase { public void MyMethod() { Console.WriteLine("MyBase::MyMethod()"); } } class MyDerived: MyBase { public void MyMethod() { Console.WriteLine("MyDerived::MyMethod()"); } } For now, without virtual and override key words. When I compile this I get the warning (which is of course expected) that I try to hide MyMethod from MyBase class. What I want to do is to call the method from the base class having an instance of derived class. I do this like this: MyDerived myDerived = new MyDerived(); ((MyBase)myDerived).MyMethod(); It works fine when I do not specify any virtual, etc. keywords in the methods. I tried to put combination of the keywords and I got the following results: | MyBase::MyMethod | MyDerived::MyMethod | Result printed on the console | | -----------------|---------------------|-------------------------------| | - | - | MyBase::MyMethod() | | - | new | MyBase::MyMethod() | | virtual | new | MyBase::MyMethod() | | virtual | override | MyDerived::MyMethod() | I hope the table is clear to you. I have two questions: Is it the correct way to call the function from the base class (((MyBase)myDerived).MyMethod();)? I know about base keyword, but it can be called only from the inside of the derived class. Is it right? Why in the last case (with virtual and override modifiers) the method which was called came from the derived class? Would you please explain that?

    Read the article

  • How to get unique URL identifier after inserting item in Google Base with Zend Gdata API?

    - by msumme
    I need to get the unique URL identifier for the product that is created after inserting an item into Google Base using the Zend_Gdata_Gbase library. I can't seem to do this. I am finding a startling lack of documentation online about manipulating the objects used in these applications. The url that I add to the object does not work to retrieve the base item later, which is why I need to get the one that google generates upon submission. I am writing a program that will need to be able to delete content at a later date, and thus will need to store that information in order to keep the website synced with the Google Base feed. Thanks in advance for any help.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >