Dynamic casting

hello all (happy new year!),
i am trying to dynamically cast a class that is only known at runtime from the configuration file that is parsed during startup.
the code is as follows:
ArrayList classes = new ArrayList();
... (parsing)
classes = JAFSaxParserInstance.getClasses();
Iterator it = classes.iterator();
while (it.hasNext())
  Object next = it.next();
  Class appToLoad = Class.forName(next.toString());
  Method instanceMethod = getInstanceMethod(appToLoad);
  Object frame = instanceMethod.invoke(null,null);
  Component[] components = new Component[MAX];
  components = ((UNKNOWN_CLASS) frame).getContentPane().getComponents();
}without the ability to discover the class from which i have just called a getInstance() method, i seem unable to retrieve all the components of the JFrame subclass (i get a ClassCastException). for my purposes, all of the UNKNOWN_CLASSes will be subclasses of JFrame, but without explicitly being able to cast it (frame) exactly, i cannot extract the components.
is there any way to dynamically cast such objects at runtime? by this i mean i cannot use switch statements b/c the classes are unknown prior to runtime.
thanks!

point well taken. i've probably designed my application wrong if it's this difficult, but let me try to explain what it is i'm trying to do.
i had previously created a swing application whose central class (bootstrap initialized by a separate class with a main method) is a subclass of JFrame using the GridBagLayout manager. now, since more related gui applications are to be built, i thought it would be nice to build an application framework into which i could insert each standalone application into a JTabbedPane pane of the framework application.
the application framework has the same structure as my previous application. a bootstrap main method class initializes the main application frame which builds a contentPane which contains a JTabbedPane. as this application framework frame is initializing, it parses an xml file which contains the data pertaining to each class and my DynamicLoader class attempts to load/initialize and add each class into a separate tab in the main application frame. that's where the problem arises since i don't know the exact class that will be loaded--only the xml file contains that information.
i've read a few things about implementing interfaces in order to get around the inability to cast types at runtime, but am not too sure of how that might work.
let me know if seeing some more of the code would help or if there's anything i should clarify.
thanks!

Similar Messages

  • Dynamic cast at runtime (Here we go again! )

    Hy folks,
    today I read so many entries about dynamic casting. But no one maps to my problem. For a lot of them individual alternatives were found. And so I hope...
    Ok, what's my problem?
    here simplified:
    I have a HashMap with couples of SwingComponents and StringArray[3].
    The SwingComponents are stored as Objects (they are all JComponents).
    The StringArray comprised "the exact ClassName" (like "JButton" or "JPanel"),
    "the method, who would be called" (like "addItemListener")
    and "the ListenerName" (like "MouseMotionListener" or "ActionListener")
    At compiletime I don't know, what JCommponent gets which Listener.
    So a JPanel could add an ItemListener, another JPanel could add
    a MouseListener and an ActionListener.
    I get the description of the GUI not until runtime.
    The 'instanceof'-resolution is not acceptable, because there are above 50 listener. If I write such a class, I would write weeks for it, and it will be enormous.
    Now, my question
    I get the class of the Listenertype by
    Class c=Class.forName(stringArray[2]);
    and the method I'll call
    java.lang.reflect.Method method=component.getClass().getDeclaredMethod(s[1],classArrayOfTheParameter[]); //the parameter is not important here
    And I have a class, who implements all required ListenerInterfaces: EHP
    Now I wish something like this
    method.invoke((JPanel)jcomponent,(c)EHP);
    Is there anybode, who can give me an alternative resolution
    without instanceof or switch-case ?
    Greatings egosum

    I see, your right. Thanks. This problem is been solved.
    But a second problem is, that jcomponent can be every Swing-Object.
    I get the swing-component as Object from the HashMap . And I know
    what it is exactly by a String.
    What I need here is
    method.invoke(("SwingType")swingcomponentObject,Object[] args);
    I know, that this doesn't exist. Here my next question
    Can I take an other structure than HashMap, where the return value
    is a safety type (and not an Object). Or there are some other hints
    about similar problems and there resolutions?
    I don't like to write 50 (or even more than 50) "instanceOf"-instructions or "equal"-queries. And I'm not really interested in the whole set of java swing elements existing.
    I appreciate all the help I can get.
    With regards egosum

  • Private inheritance and dynamic cast issue

    Hello. I am hitting a problem combining private inheritance and dynamic casting, using Sun Studio 12 (Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25):
    I have three related classes. Let's call them:
    Handle: The basic Handle class.
    DspHandle. Handle implementation, able to add itself to a Receiver.
    IODriver. Implemented in terms of DspHandle, It is the actually instantiated object.
    Consider the following code. Sorry, but I've tried my best trying to minimize it:
    #include <iostream>
    using namespace std;
    class Handle {
    public:
    virtual ~Handle() {};
    class Receiver {
    public:
    void add(Handle &a);
    class DspHandle : public Handle {
    public:
    virtual ~DspHandle() {};
    void run(Receiver &recv);
    class IODriver : private DspHandle {
    public:
    void start(Receiver &recv) {
    DspHandle::run(recv);
    void DspHandle::run(Receiver &recv) {
    cout << "Calling Receiver::add(" << typeid(this).name() << ")" << endl;
    recv.add(*this);
    void Receiver::add(Handle &a) {
    cout << "Called Receiver::add(" << typeid(&a).name() << ")" << endl;
    DspHandle d = dynamic_cast<DspHandle>(&a);
    cout << "a= " << &a << ", d=" << d << endl;
    int main(int argc, char *argv[]) {
    Receiver recv;
    IODriver c;
    c.start(recv);
    Compiling and running this code with Sun Studio 12:
    CC -o test test.cc
    ./test
    Calling Receiver::add(DspHandle*)
    Called Receiver::add(Handle*)
    a= ffbffd54, d=0
    The dynamic cast in Receiver::add, trying to downcast Handle to DspHandle, fails.
    This same code works, for example with GNU g++ 4.1.3:
    Calling Receiver::add(P9DspHandle)
    Called Receiver::add(P6Handle)
    a= 0xbfe9c898, d=0xbfe9c898
    What is the reason of the dynamic_cast being rejected. Since the pointer is actually a DspHandle* , even when it is part of a private class, shouldn't it be downcastable to DspHandle? I think that perhaps the pointer should be rejected by Receiver::add(Handle &a) as it could be seen as a IODriver, that can't be converted to its private base. But since it's accepted, shouldn't the dynamic_cast work?
    Changing the inheritance of IODriver to public instead of private avoids the error, but it's not an option in my design.
    So, questions: Why is it failing? Any workarround?
    Best wishes.
    Manuel.

    Thanks for your fast answer.
    But could you please provide a deeper answer? I would like to know where do you think the problem is. Shouldn't the reference be accepted by Receiver:add, since it can only be seen as a Handle using its private base, or should the dynamic_cast work?
    Aren't we actually trying to cast to a private base? However, casting to private bases directly uses to be rejected in compile time. Should the *this pointer passed from the DspHandle class to Receiver be considered a pure DspHandle or a IODriver?
    Thanks a lot.

  • Dynamic casting of Method.invoke() return

    Can anyone clue me in on how to cast the return of Method.invoke() based on Method.getReturnType() or whatever else might work dynamically....that is without knowing which method until runtime?
    Thanks,
    Brad

    Thanks for helping me get a grip....makes perfect sense, I guess I was just wondering how far you could take the runtime decisions thing.
    Can I say that, ( and it seems obvious but... ), programatic flexibility and runtime decision making can only be taken so far - and has to be made in the context of certain presumptions at compike time.
    I can see that in implementing the:
    <jsp: setParameter name="myBean" property="*" />
    Presumptions are made that the values passed to
    the bean setter methods will be String objects and that the
    values returned from the:getter methods using:
    <jsp: getProperty name="myBean" property="whaterver" />
    will also be String objects.
    Reality check?
    Thanks again,
    Brad

  • Problem during dynamic casting

    Hi Guys,
    Need you help
    Situation is like this �.I have a function which accept the Sting parameter
    Which is actually a full name of class �.using reflection I created the class and object
    Now I want to cast this newly created object to their original class type
    Code is somehow like this
    Public void checkThis (String name) throws Exception{
    Class c = Class.forName(name.trim());
    Object o = c.newInstance();     
    System.out.println(" class name = " + c.getName());
    throw ()o; //// here I want to cast this object to their orginal class type
    I tried throw (c.getName())o;
    But it is not working
    }

    You are trying to do the impossible, for example, this just doesn't work:
    String classname = ...
    Class cls = Class.forName(classname);
    Object obj = cls.newInstance();
    classname x = (classname) obj; //??? There is no way to name this legal syntax!Solution: you must statically know an interface or superclass for the dynamic class:
    Runnable r = (Runnable) obj;
    new Thread(r).start(); //etcOr work with the Object reference, using reflection to apply methods, etc.
    Message was edited by:
    DrLaszloJamf

  • Dynamic casting in java

    Hello everyone....
    i am having a problem as follows:
    i have a method in my project which is taking a reference of object type...
    i want to cast the object to the passing type,bt i dont want to cast explictily inside the method...
    can something be done by which the object itself get casted to passing type automatically by determining the runtime of the instance being passesd at runtime?
    public void change(Object o)
    /// i want to cast this object to A type without explicit casting.... can it be done through reflection or some other method?
    call of the above method from main///
    p.s.v.main(String[] args)
    A a =new A();
    a.call(new A());
    }

    807784 wrote:
    can something be done by which the object itself get casted to passing type automatically by determining the runtime of the instance being passesd at runtime?When you cast an Object to a specific class or interface you are telling the compiler that the object is really of that class or interface. The only thing a cast does at run time is to verify that the actual object is of the specified class. Hence, for a cast to do any good, it must be present at compile time.
    I don't know exactly what you are trying to do, but you might want to look at the visitor pattern.

  • Newbie question: ""dynamic"" casting

    Hello all,
    <br>
    I have a quite newbie question. I have this class hierarcy:
    <br>
    A
    |_A1
    |_A2
    |_A3
    |_A4
    |_A5
    |_.....
    <br>
    in some part of my code I have this:
    <br><br>
    if (object1 instanceof A){
    if (object1 instanceof A1)      {A1   object2 = (A1) e;}
              if (object1 instanceof A2)      {A2   object2 = (A2) e;}
              if (object1 instanceof A3)      {A3   object2 = (A3) e;}
              if (object1 instanceof A4)      {A4   object2 = (A4) e;}
              if (object1 instanceof A5)      {A5   object2 = (A5) e;}
    object2.callMethod();
    <br><br>
    Is there any way to do this type of casting just in one line? I mean, I just want to cast object1 to the class it is instanceof. If it is instance of A1, I want to be casted to A1, if it is A2 to A2, etc...
    <br><br>
    Thanks you in advance.

    kamikaze04 wrote:
    In fact I know what object1 is on execution time,Which doesn't help your compiler at all, when it's task to link and verify method calls.
    because the code posted at the top is working well, i just want to avoid repeating that if's for all the new classes Ax I will create. Big "code smell" here.
    In other words if i had from A1 to A200 i dont want to have 200 if's to cast it to the class it is and then execute it's method.You could call the method "doMagic()" and make it abstract in A. Then you can implement it in all Ax classes and would never have to worry about casting in the first place, because A.doMagic() would automagically do the right thing. Polymorphism.

  • Problem during dynamic casting (using reflection)

    Hi Guys,
    Need you help
    Situation is like this �.I have a function which accept the Sting parameter
    Which is actually a full name of class �.using reflection I created the class and object
    Now I want to cast this newly created object to their original class type
    Code is somehow like this
    Public void checkThis (String name) throws Exception{
    Class c = Class.forName(name.trim());
    Object o = c.newInstance();     
    System.out.println(" class name = " + c.getName());
    throw ()o; //// here I want to cast this object to their orginal class type
    I tried throw (c.getName())o;
    But it is not working
    }

    You can't cast to an unknown type like that. You're trying to throw the object, which makes me believe you're loading and instantiating some Exception or other, right? Just cast the result to something generic, like Exception, or RuntimeException, or maybe Throwable. As long as the class you load actually is a subclass of whichever you choose, you'll be fine. And if it isn't, you've got problems anyway because you can't throw anything that isn't Throwable

  • Casting the Object dynamically

    Hi All,
    I am looking for a way to dynamically cast the object. I am receiving an object which is JAXB object as parameter of a method. This object can be type pf one the 5 jaxb objects my logic is handling. I need to identify the actual type of object and perform some operations on it.
    Each of these 5 JAXB objects have some common method (although these objects does not inherit from any common class) and some methods which are specific to them.
    I can not make changes to JAXB classes as i am importing those as jar.
    I know it will need reflection somehow but i am not sure how to do it exactly. Below code will give you idea what i am trying to achieve. Its giving compile time error as xngEvent is typecasted in if-else block. This is just to show what i want to achieve using reflection.
    public void processMessage(Object inputObject)
    if(inputObject instanceof com.att.granite.jaxb.xngevents.dtd.equipment.XngEvent){
                        com.att.granite.jaxb.xngevents.dtd.equipment.XngEvent xngEvent = (com.att.granite.jaxb.xngevents.dtd.equipment.XngEvent)inputObject;
                   }else if(inputObject instanceof com.att.granite.jaxb.xngevents.dtd.cable.XngEvent){
                        com.att.granite.jaxb.xngevents.dtd.cable.XngEvent xngEvent = (com.att.granite.jaxb.xngevents.dtd.cable.XngEvent)inputObject;
                   }else if(inputObject instanceof com.att.granite.jaxb.xngevents.dtd.ipaddress.XngEvent){
                        com.att.granite.jaxb.xngevents.dtd.ipaddress.XngEvent xngEvent = (com.att.granite.jaxb.xngevents.dtd.ipaddress.XngEvent)inputObject;
                   }else if(inputObject instanceof com.att.granite.jaxb.xngevents.dtd.ipsubrange.XngEvent){
                        com.att.granite.jaxb.xngevents.dtd.ipsubrange.XngEvent xngEvent = (com.att.granite.jaxb.xngevents.dtd.ipsubrange.XngEvent)inputObject;
                   }else if(inputObject instanceof com.att.granite.jaxb.xngevents.dtd.path.XngEvent){
                        com.att.granite.jaxb.xngevents.dtd.path.XngEvent xngEvent = (com.att.granite.jaxb.xngevents.dtd.path.XngEvent)inputObject;
                   }else{
                        com.att.granite.jaxb.xngevents.dtd.site.XngEvent xngEvent = (com.att.granite.jaxb.xngevents.dtd.site.XngEvent)inputObject;
    String database = xngEvent.getDatabase();
    String elementType = xngEvent.getElementType();
    String editOperation = xngEvent.getEditOperation();
    validateEvent(elementType,editOperation,xngEvent);Thanks,
    Aashu

    What you are talking about is called runtime class working. It can do the job you want but for reasons the other responders already mentioned I cannot recommend it for your use case. The primary reasons being the complexity involved, the likelihood that you will need changes that will not be backward compatible, the difficulty in testing and debugging and the difficulty in finding developers that will even understand this approach that can take over after you are gone.
    This type of functionality is very roughly related to the use of dynamic proxies and code injection used by Spring and other frameworks.
    With those caveats in mind this is a link with an excellent example of how to do it and the issues involved.
    http://www.ibm.com/developerworks/java/library/j-dyn0610/
    For your use case I would recommend the approach you have probably already settled on. But first follow gimbal2's advice and document your requirements and use case and the dependencies on possibly duplicated code sections you previously mentioned.

  • Dynamic typecasting for re-usability

    Hi there,
    I'm trying to dynamically cast an object to a class only known at runtime. All that is known at compile time is the name and type of a variable inside the object - and that is all that is of interest. The reason for this is to create re-usable code to allow multiple classes to be used as peers (all owned by the unknown class) together.
    I have a method (provided, so I can't change it) getOwner() that gives me the parent class, but as type Object. I need to re-cast it to the correct class to be able to access its content. I know ahead of time that the variable knownvar will exist in the parent class, and I know what type it will be.
    So instead of doing:
    if(this.getOwner().getType() == "ClassA")
      (ClassA)this.getOwner().knownvar = somevalue;
    else if(this.getOwner().getType() == "ClassB")
      (ClassB)this.getOwner().knownvar = somevalue;
    elseif ... (ad nauseum)I'd rather like to do something similar to this (this does not work):
    (this.getOwner().getType())this.getOwner().knownvar = somevalue;In fact, I'd prefer not to do the whole list of elseifs if at all possible, since it limits possible future use to pre-thought of class names - and adding some that might not exist (also bad).
    Any suggestions on how this can be done?

    Thank you for the replies! (Especially Loko for that possible workaround)
    Yes indeed, it is quite a bad design and I flinch at having to hack things so badly. It is not a clean and elegant design when done like this. Unfortunately I have no choice but to use a workaround. I'll try your suggestion and see if it can do the trick.
    duffymo - As for using if checks - that is exactly what I don't want to use exactly because it is not object oriented - but is a way to express and explain to others what kind of function I am trying to perform. I'd perfer to use something like my second code snippet where no prior knowledge of the class is needed. I need to cast, otherwise the knownvar property is not accessable. Unfortunately, like I said, I do not have control over the interface, so I need a workaround.
    There is also a small chance I might be able to convince the supplier of the owner class to implement this better by using an intermediate class that extends the one providing "Object getOwner()", returning a more specific class that expresses the presense of knownvar. I am using Java code fragments inside a third-party product, so it might not be possible to make this change within the timescales available.

  • Runtime Casting

    I have a hashtable with different objects types inside it. Since they are swing objects, all of them are handled by a single function.
    Enumeration enum = hash.keys();
    while( enum.hasMoreElements() )
         // The key is always a String, so a hard cast is acceptable
         String key = (String)enum.nextElement();
         Object val = hash.get(key);
         // Try Use Reflection to retrieve the class
         Class interfaceClass = Class.forName(val);    // ??
         panel.add( (interfaceClass)val  );            // ??
    }What I would like to do is cast these objects without having to write a switch statment to delimit hard casts. The following code works, but since I have to hard code the answers is *obviously a poor way to do it.
    Enumeration enum = hash.keys();
    while( enum.hasMoreElements() )
         String key = (String)enum.nextElement();
         Object val = hash.get(key);
         // Use Reflection to retrieve the class
         Class interfaceClass = val.getClass();
         String className = interfaceClass.getName();
         if( className.endsWith("JButton") )
              panel.add( (JButton)val  );
         else if( className.endsWith("JCheckBox") )
              panel.add( (JCheckBox)val  );
    }Any help with the dynamic casting problem would be appericated.
    ~Kullgen
    (PS, After searching the forums for a solution, I find that when people ask this question they are invariably flamed for poor design. This is not a design question, but just a problem with having to use the clunky java swing. IMHO Swing was very poorly designed, and thus leaves itself open to the problems above. I want this to be a post about runtime casting, not about design)

    Since all the has elements are Swing componets they are all instances
    of java.awt.Component. So simply cast to that and everything will be
    just fine and dandy. No need for lots of switch statements.
    For example:
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    public class Kullgen1
         public static void main(String[] argv)
              Hashtable hash= new Hashtable();
              hash.put("Button", new JButton("Button"));
              hash.put("Label", new JLabel("Label"));
              hash.put("TextField", new JTextField("TextField"));
              JFrame frame= new JFrame();
              JPanel panel= new JPanel(new GridLayout(0,1));
              frame.getContentPane().add(panel);
              Iterator components= hash.values().iterator();
              while(components.hasNext())
                   panel.add((Component) components.next());
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.pack();
              frame.setVisible(true);
    }

  • E3 2014 Announcements and Best Buy

    The Electronic Entertainment Expo, commonly referred to as E3, is happening in Los Angeles this week from June 10-12, 2014. I’m sure most of you, me included, are unable to attend the event, but are still very interested in staying up-to-date with all of the news and announcements happening throughout the week. To help you stay in the loop with all things E3 and how they relate to Best Buy, I’m going to be doing everything I can to keep this post updated with announcements as they happen and let you know when any newly announced games are available for pre-order at Best Buy.
    Tell your friends, bookmark this post, and be sure to keep checking back throughout the week for updates, to ask questions, interact with our gaming community and discuss what you’re excited about!
    Announcements from the Xbox Press Conference
    They began by talking about previously announced games still to come in 2014, revealing some release dates for these games as well, followed up with some newly announced titles. See the titles they talked about below. If you don't see pre-order links for certain titles just yet, stay tuned! We'll be working to get them listed as quickly as possible.
    Call of Duty: Advanced Warfare
    My Best Buy members get $10 in reward certificates when they pre-order and purchase Call of Duty: Advanced Warfare. Learn more
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    Available 11/4/14
    Forza Horizon 2
    Plunge into the fast-paced world of open-road racing with Forza Horizon 2 as you take the wheel of a variety of the greatest cars ever made. Get behind the wheel of more than 200 vehicles, including extreme off-roaders, modern supercars, classic muscle and more, all with authentic interiors and full cockpit views. Compete in races, seek out hidden treasures or unlock exciting bucket list challenges with versatile gameplay.
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    Available 9/30/14
    Evolve
    In a savage world of man vs. nature, are you the hunter or the hunted? The creators of Left 4 Dead, Turtle Rock Studios, bring you Evolve, the next-generation of multiplayer shooters where four hunters face off against a single, player-controlled monster. Stalk your prey, execute your attack and prove you are the apex predator in adrenaline-pumping 4V1 matches.
    My Best Buy members get $10 in reward certificates when they pre-order and purchase Evolve. Learn more
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order to receive The Monster Expansion Pack Pre-Order Bonus
    Pre-order now here
    Coming Fall 2014
    Sunset Overdrive
    Dive into the open-world shooter of Sunset Overdrive, and prove that you've got what it takes to survive catastrophe. With a knack for traversing the ruined city with hyper agility, it's a simple matter to survive postapocalyptic conditions. When it comes to the mutants, not only are you escaping their transformation, but you've found your true calling — mutant destroyer. A fully loaded arsenal of overpowered weapons back you up and make it totally clear that the end of days is just the beginning for you.
    My Best Buy members get $10 in reward certificates when they pre-order and purchase Sunset Overdrive. Learn more
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order to receive a can koozie as well as the Fisco Bot outfit and AK-FOFF fun, only at Best Buy
    Pre-order now here
    Available 10/28/14
    Halo: The Master Chief Collection
    The iconic helmet and armor. The legendary story. The heart-racing combat. Halo has defined a generation of action-packed gaming and online multiplayer gameplay for more than a decade. Now, you can re-experience the thrills, adrenaline and immersive storylines of the Halo franchise, remastered and revamped for the Xbox One. With The Master Chief Collection, you'll not only receive stunning visuals, white-knuckle adventures and deep, rich storylines, you'll have a chance to honor the iconic hero who has been central to so many of your gaming conquests.
    Includes Halo: CE Anniversary, Halo 2: Anniversary, Halo 3 and Halo 4 for Xbox One along with the Halo: Nightfall digital series
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order to receive a multiplayer map guide and in-game Grunt Funeral Skull, only at Best Buy
    Pre-order now here
    Available 11/11/14
    Halo 5: Guardians
    My Best Buy members get $10 in reward certificates when they pre-order and purchase Halo 5: Guardians. Learn more
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    ScaleBound
    Set off for an epic adventure in the latest creation of renown game director Hideki Kamiya, Scalebound. Journey to a hostile, far-off world full of danger and excitement. Face a horrific assortment of strange, powerful creatures. Preserve the future by developing a bond with a towering dragon. The fate of two worlds lies in your hands — can you rise to the challenge?
    My Best Buy Gamers Club Unlocked members get 20% off.Learn more
    Pre-order now here.
    Crackdown
    Return to the action-packed gameplay of Crackdown with an all-new experience developed by the game's original creator, Dave Jones, as you get your hands dirty and run out the crime-crazed mutants of Pacific City. Take the fight upward with amazing verticality, and lay waste to the freakish menace with brutal mayhem and mind-blowing levels of destruction in co-operative gameplay. Take to the overrun streets with friends in Campaign mode, or go head-to-head in competition on Xbox Live. Brace yourself — these mutants are about to get even uglier.
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    Rise of the Tomb Raider
    Join Lara Croft on her next adventure in Rise of the Tomb Raider as she harnesses all of her survival skills on the quest to embrace her fate as a Tomb Raider — and make it out alive. Explore the vastness of a strikingly beautiful environment where lethal threats lurk around every corner. Take your abilities to the limits as you enter the ominous darkness of tombs and fight for survival. Experience the heart-pounding thrill of action like never before with the Foundation engine, and greet a dynamic cast composed of new faces rendered in amazing clarity. Immerse yourself in Lara's world with an intense performance delivered by Camilla Luddington in a mind-blowing story that reveals the character's deepest turmoil and motivations, created by a writing team led by award-winning author Rhianna Pratchett.
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    Project Spark
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    Phantom Dust
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    Disney Fantasia: Music Evolved
    Available 10/21/14
    Announcements from the EA Press Conference
    EA also went through some previously announced titles along with showing footage of new titles. See the titles EA talked about below. If you don't see pre-order links for certain titles just yet, stay tuned! We'll be working to get them listed as quickly as possible.
    Dragon Age: Inquisition
    Dark times have come to Thedas — monstrous dragons cast ominous shadows from above while chaos erupts all around you. What was once a land of peace and happiness is now ripped apart by conflict as the Mages wage bloody battle against their oppressors, the Templars. Someone must restore order to Thedas and put an end to those who seek to destroy the land. It's time to lead the Inquisition — a band of legendary heroes and the only hope of Thedas — and wage a war to end this reign of terror.
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order to receive the Dragon Age Inquisition Weapons Arsenal Pre-Order Bonus
    Pre-order now here
    Available 10/7/14
    The Sims 4
    In The Sims 3, you got the opportunity to throw open the doors and explore the neighborhood — well in The Sims 4, it's time to look within the mind, body and heart of your Sims for an amazingly rich and incredibly lifelike story that you won't forget. The beauty of The Sims is that it simulates life and hands the controls over to you, but what is life without emotion? For the first time, your Sims feel and express emotions with a diverse range and depth that can be influenced by other Sims, actions, memories or even the clothing and objects you choose. What could be more true to life than that?
    My Best Buy members get $10 in reward certificates when they pre-order and purchase Sims 4. Learn more
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    Available 9/2/14
    EA Sports UFC
    Fans of MMA fighting know that no other sport in the world matches the intensity that can be found in this arena. It takes more guts and skill than most people have to be a UFC fighter — but EA Sports UFC gives the rest of the world a chance by bringing the fight to your PlayStation 4 powered by EA Sports Ignite technology. EA Sports UFC takes the action, emotion and intensity that can only be found inside the Octagon and combines it with the amazing abilities of this next-generation console for an adrenaline-pumping, heart-pounding, guts-or-glory kind of experience that you won't soon forget. Are you ready to feel the fight?
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order to receive the EA Sports UFC Bruce Lee Pre-Order Bonus
    Purchase now here
    Available 6/17/14
    NHL 15
    Return to the rink with NHL 15, the latest installment in the series known for intense hockey action. Experience the thrill of the game with 12-Player NHL Collision Physics that provide hard-hitting collisions and player pile-ups. Test your skills in authentic playing conditions with Real Puck Physics that create realistic ice surfaces and puck motion to duplicate the unpredictable spins, rolls and bounces seen in nonstop NHL action. Enjoy the look and feel of a real game with the Next-Generation Hockey Player, modeled on authentic player and equipment models to deliver unprecedented player likenesses, emotions and animations.
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    Available 9/9/14
    Madden NFL 15
    Madden NFL 15 delivers everything you need to own your rivals on both sides of the field, including the most immersive defensive gameplay in franchise history. With all-new player-lock camera angles, pass rush tools, open-field tackling mechanics and smarter AI, you've never been more armed to take control of the defense and challenge the best offenses in the game. Madden NFL 15 introduces a revolutionary crowd-sourced play-calling system with three distinct ways to run offense and defense: coach suggestions, Madden community picks and concept plays providing a strategic edge to take on all rivals. 
    My Best Buy members get $10 in reward certificates when they pre-order and purchase Madden NFL 15. Learn more
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    Available 8/26/14
    FIFA 15
    Battle the world's best players and witness their expressions of intensity, celebration and defeat detailed in lifelike accuracy with Emotional Intelligence modeling. Contend with the conditions of the pitch and realistic interactions between players, the ball and their environment with Physically Correct Contacts that re-create dribbles, touches, passes, shots and deflections in relation to the position of the body part or object with which they connect. Plunge into the physicality of head-to-head competition with intense Man-to-Man Battles that test your skills and endurance and establish dominance with Full-Body Defending. 
    My Best Buy members get $10 in reward certificates when they pre-order and purchase FIFA 15.Learn more
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    Battlefield Hardline
    Brought to you from the studio that created Dead Space, Battlefield Hardline's innovative and dramatic single-player storyline plunges you into the role of Nick Mendoza, a young detective who is determined to exact revenge against once-trusted partners on the force. Then, engage in intense multiplayer action for up to 64 players that features the strategic team play, variety and immersion of Battlefield, set in an all-new playground with cops-and-criminals-inspired gameplay — hunt criminals, save hostages, raid vaults and more.
    My Best Buy members get $10 in reward certificates when they pre-order and purchase Battlefield Hardline.Learn more
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    Available 10/21/14
    Mass Effect 4
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    EA Sports PGA Tour
    Available Spring 2015
    Star Wars Battlefront
    Mirror's Edge 2
    Announcements from the Ubisoft Press Conference
    See the titles Ubisoft talked about below. If you don't see pre-order links for certain titles just yet, stay tuned! We'll be working to get them listed as quickly as possible.
    Far Cry 4
    Journey deep into the Himalayas to Kyrat, a breathtaking, perilous and wild region. Explore an expansive open world where anything can happen and danger hovers all around you. Receive a Limited Edition upgrade with pre-order, which includes Hurk's Redemption with three single-player missions that put you on the hunt for a rare artifact, plus a devastating Impaler harpoon gun. Will you rise to the challenge and set Kyrat on the path to freedom?
    My Best Buy members get $10 in reward certificates when they pre-order and purchase Far Cry 4. Learn more
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order to receive The Butcher's Machete, only at Best Buy
    Pre-order now here
    Available 11/18/14
    Tom Clancy’s The Division
    Dive into the frighteningly chaotic and devastated New York City as an agent of The Division, working to restore order. Call upon your skills, weapons and wits as you play in this persistent, dynamic environment that combines the Tom Clancy series' core authenticity and tactical decisions, RPG action, trading and much more. Join your skills with your friends' as you create a team of agents called upon to investigate the source of the virus and engage all threats, even if it means taking down your own citizens.
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    Available 2015
    The Crew
    Put the pedal to the metal and get behind the wheel in The Crew, a next-gen racing adventure that allows you to explore the U.S. in its entirety, from coast to coast. Build your crew of four through companionship or rivalrous adversity, and then embark on your quest to improve your rep in the underground-racing world and infiltrate and ultimately overtake the 510s, a gang grown around Detroit's street-racing scene.
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now here
    Available 11/11/14
    Assassin's Creed Unity
    My Best Buy members get $10 in reward certificates when they pre-order and purchase Assassin's Creed Unity. Learn more
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order to receive chances to win prizes with the Spin to Win game, the Chemical Revolution and a Best Buy exclusive Over Under pistol.
    Pre-order now here
    Pre-order the Collector's Edition here
    Available 10/28/14
    Just Dance 2015
    Head to the dance floor as you take your performances to a whole new level in the latest installment of the popular Just Dance franchise, Just Dance 2015. Get everyone moving with the latest jams from Pharrell Williams, Ellie Goulding, Calvin Harris, John Newman and more, and take a trip down memory lane with classics by Bonnie Tyler and Run DMC & Aerosmith.
    My Best Buy Gamers Club Unlocked members get 20% off.Learn more
    Pre-order now here
    Tom Clancy's Rainbow Six Siege
    Return to the heart-pounding shooter action of the Tom Clancy's Rainbow Six franchise with Tom Clancy's Rainbow Six Siege, an all-new installment that takes you deep inside the thrilling and dangerous world of a global counter-terrorist operative as you fight to make the world a safer place. Jump into action as you engage in fast-moving, close-quarters combat, carry out intense coordinated assaults, execute sharply tuned strategies and of course, blow away anything that stands in your way with explosive demolitions skills.
    My Best Buy Gamers Club Unlocked members get 20% off. Learn more
    Pre-order now 

    Is there anyway you can try to get more images/videos for the Battlefield Hardline? Personally I found BF4 a disappointment from BF3 so I am still 50/50 on even ordering this one.
    Any news for PC GTA V yet?
    I am not affiliated with Best Buy nor have I ever been employed by Best Buy. All of my thoughts and posts are of my own opinion and personal experience.
    I may not always know the right answer, but I will always tell you what I do know. I also do free computer analysis and consultation via private message.

  • Virtual function overriding

    Hi
    I am having a strange problem in my application. I have a virtual method in a base class which I override in the sub class. In my application I instantiate the subclass . This virtual function is then called from a function in the base class . Most of the time this works okay i.e. the overriden function from the subclass gets called but sometimes , for some reason , the base class function gets called , although I verified that the subclass has been instantiated properly.
    Any ideas what the problem could be ? . Is there any way to debug this , or view the virtual funtion table.
    Any help would be highly appreciated.
    Thanks
    Santosh

    1. Probably you have slicing problem, it happens when you are passing your derived class object where you have defined to pass base class object. In this case your derived class object will be sliced and you will have base class object.
    You have two solutions-
    1. First thing is you should define the functionality of this function in the base class, bcs it seems this functionality belongs to base class as you are trying to use it there.
    2. Dynamically cast the object to your derived class and then call the function. See if it helps.

  • Need to send object instances over the network

    I found no other way to implement a switch case to cast objects on both sides to solve my problem.
    Basically I need to send objects over a network protocol based on XML, the object is sent inside XML
    converted in base64, overall encoding of XML is utf-8.
    Let's suppose in my network there are 2 peers connected via socket.
    I have multiple instances of different types on both peers but I want to keep these instances
    synchronized. If something changes on side A, side B must receive that instance and replace
    it in the correct place (just one way, from A to B).
    When I receive such instance on B I want to cast it to it's proper instance
    of it's proper type and I am scratching my head on how could I implement this without some
    sort of unique ID table and switch case.
    If I had 1 instance per type could it be done easily?
    But I need to keep in synch many instances per type.
    Is there any dynamic casting that I can trigger based on some type/instanceID information
    I could send along the object?

    I found no other way to implement a switch case to cast objects on both sides to solve my problem.
    Basically I need to send objects over a network protocol based on XML, the object is sent inside XML
    converted in base64, overall encoding of XML is utf-8.
    Let's suppose in my network there are 2 peers connected via socket.
    I have multiple instances of different types on both peers but I want to keep these instances
    synchronized. If something changes on side A, side B must receive that instance and replace
    it in the correct place (just one way, from A to B).
    When I receive such instance on B I want to cast it to it's proper instance
    of it's proper type and I am scratching my head on how could I implement this without some
    sort of unique ID table and switch case.
    If I had 1 instance per type could it be done easily?
    But I need to keep in synch many instances per type.
    Is there any dynamic casting that I can trigger based on some type/instanceID information
    I could send along the object?

  • How to create object by getting class name as input

    hi
    i need to create object for the existing classes by getting class name as input from the user at run time.
    how can i do it.
    for exapmle ExpnEvaluation is a class, i will get this class name as input and store it in a string
    String classname = "ExpnEvaluation";
    now how can i create object for the class ExpnEvaluation by using the string classname in which the class name is storted
    Thanks in advance

    i think we have to cast it, can u help me how to cast
    the obj to the classname that i get as inputThat's exactly the point why you shouldn't be doing this. You can't have a dynamic cast at compile time already. It doesn't make sense. Which is also the reason why class.forName().newInstance() is a very nice but also often very useless tool, unless the classes loaded all share a mutual interface.

Maybe you are looking for

  • Pics not showing up in library after I quit application

    Lately, after importing pics to the iPhoto library... I see them UNTIL I quit the application. Then, when I reopen it... the pics just imported are NOT there. Help Please!

  • Does anybody here know how I can compile my java programs?

    I downloaded j2se 1.4.0 and j2se 1.4.1 and for some reason I can't the javac command in the bin directory. There is a command called javaw but I don't know what it does. can anyone help me?

  • Importing of material master from SAP to MDM

    Hi all we are working for a scenario where we need to import data from SAP R/3 to MDM using IDoc and XI.MDM already provides standard T codes for collective generation of IDocs for vendor and customer master( what i mean is single IDoc is generated f

  • Best approach to reduce size of 400GB PO (yikes!)

    Hi fellow Groupwise gurus, Am taking a position with a new company that has just informed me they have a 400GB PO message store. I informed them that, uh yea, this is a bit of a problem. So, I am starting to consider best way(s) to deal with this. Th

  • New Themes and Extra Large Book format not working

    I can't access the new themes or the new large format book in iPhoto. I have installed the 8.1 upgrade. (I also have installed Snow Leopard). 8.1 seems to have installed successfully, but I still can't get the new stuff, so I tried re-installing it,