Integration Notes

[Machine Vision, Illumination] [Java, J2EE][LabVIEW ] [ORACLE ] [C++ ] [C#] [Aspect-Oriented Programming] [Embedded] [XP Agile CI]

C++

C++/CLI
XP - CPP Unit - Agile
  • CPP Unit Framework
    • Borland’s Suite of Software Quality Assurance, Control & Management Products
    • Borland® SilkCentral® Test Manager™: Automated software test management tool.
    • Borland Gauntlet®: Builds and tests code as it enters version control, isolates defects and reports on development metrics with a continuous integration and code coverage tool.
    • Borland SilkTest®: Automated regression and functional software testing that includes intuitive GUI record-and-play capabilities and a stable, straightforward testing language.
    • Borland SilkPerformer®: Automates software application performance and load testing.
Win32
Not all Windows come with text. For reverse egineering, I found, occasionally it's handy to see the BitBlited Bitmap of Windows in onrder to find relation of visible Window to the closest Window with Text.
[Download Handle Visualizer (RAR'ed).] [Download un-RAR utility] Easy to use!!
  • Tried on Win2000, WinXP and Vista.
  • Helps to relate HWND of a visible Window to HWND of the closest Window that contains an item that could be found from the code (FindWindow).
  • Blinks the Window associated with a selected handle. You do the selection by double-clicking on the item on a list.
  • Blinking may be applied to the Windows of the Visualizer itself. That may confuse you, or force to compete with the timer to get out of the loop.
      To avoid confusion be aware that:
    • There is a small delay before the Window starts blinking. This is hard coded.
    • In order to initiate blinking one must click on line in one of List Boxes. One Tab holds a List Box that contains all Window handles; another Tab holds a Listbox that contains handles to visible Windows. Finally third tab holds a ListBox that contains results of a search. Blinking does not start unless the selected line contains a word handle.
    • In order to stop blinking click any of the buttons in upper part of the Visualizer's GUI. (Root, on search side (left side) gives the fastest response)
    • Note that one may minimize Windows that were hidden and wonder what they are.
    • Windows that are hidden behind another windows will render white or overlapped bitmaps. Move the window that obstructs the view and double-click on the item on the list again.
    • Application discriminates some Windows. Let me know if it should discriminate even more.
Code Snippets
Declarations
int **p1;  //  p1 is a pointer   to a pointer   to an int.
int *&p2;  //  p2 is a reference to a pointer   to an int.
int &*p3;  //  ERROR: Pointer    to a reference is illegal.
int &&p4;  //  ERROR: Reference  to a reference is illegal.

char ** p1; // pointer to pointer to char const char **p2; // pointer to pointer to const char char * const * p3; // pointer to const pointer to char const char * const * p4; // pointer to const pointer to const char char ** const p5; // const pointer to pointer to char const char ** const p6; // const pointer to pointer to const char char * const * const p7; // const pointer to const pointer to char const char * const * const p8; // const pointer to const pointer to const char
typedef char * a; // a is a pointer to a char typedef a b(); // b is a function that returns a pointer to a char typedef b *c; // c is a pointer to a function that returns a pointer to a char typedef c d(); // d is a function returning a pointer to a function that returns a pointer to a char typedef d *e; // e is a pointer to a function returning a pointer to a function that returns a pointer to a char e var[10]; // var is an array of 10 pointers to functions returning pointers to functions returning pointers
float ( * ( *b()) [] )(); // b is a function that returns a // pointer to an array of pointers // to functions returning floats. void * ( *c) ( char, int (*)()); // c is a pointer to a function that takes // two parameters: // a char and a pointer to a // function that takes no // parameters and returns // an int // and returns a pointer to void. void ** (*d) (int &, char **(*)(char *, char **)); // d is a pointer to a function that takes // two parameters: // a reference to an int and a pointer // to a function that takes two parameters: // a pointer to a char and a pointer // to a pointer to a char // and returns a pointer to a pointer // to a char // and returns a pointer to a pointer to void float ( * ( * e[10]) (int &) ) [5]; // e is an array of 10 pointers to // functions that take a single // reference to an int as an argument // and return pointers to // an array of 5 floats.
Passing a pointer to member function, that is to a method, to a global function.
// CSomeClass.h
class CSomeClass{
    public:
    CSomeClass(void){};
    ~CSomeClass(void){};
    char* GetFieldValue(int nField);
    char* GetFieldName(int nField);
    static char * GetFieldValueStatic(int nField);
    static char * GetFieldNameStatic(int nField);
};
//CSomeClass.cpp
CSomeClass::CSomeClass(void){};
CSomeClass::~CSomeClass(void){};
char * CSomeClass::GetFieldValue(int nField){ return "Field Value stub";}
char * CSomeClass::GetFieldName(int nField){ return "Field Name stub";}
char * CSomeClass::GetFieldValueStatic(int nField){ return "Static Field Value stub";}
char * CSomeClass::GetFieldNameStatic(int nField){ return "Static Field Name stub";}

//
// Win32 console
// gFncTest  and gFncTestStatic are global functions in question.
// Parentheses around (CSomeClass::*funPName) are required since * binds
// less tightly, has lower precedence, than the function call.
//
void gFncTest( char * (((CSomeClass::*funPName))(int)), CSomeClass* cp )
{
    for ( int k =0; k < MAX_ITEMS_TO_PRINT; k++){ printf((cp->*funPName)(k)); printf("\n");}
    return;
}

void gFncTestStatic ( char* (*kk)(int) ){
    for ( int k =0; k < MAX_ITEMS_TO_PRINT; k++) { printf(kk(0)); printf("\n");}
    return;
}


int main(int argc, _TCHAR* argv[]){
    //  without qualifier 'static'  compiler reports: 
    //  cannot convert parameter 1 from 
    //  'char *(__thiscall COracle::* )(int)' to 'char *(__cdecl *)(int)'
    gFncTestStatic (&COracle::GetFieldValueStatic);

    CSomeClass * cp = new CSomeClass();
    // invoke this way
    gFncTest (&CSomeClass::GetFieldName, cp);
    gFncTest (&CSomeClass::GetFieldValue, cp);
    
    // or invoke this way
    char * (CSomeClass::* functPointName)(int) = &CSomeClass::GetFieldName;
    gFncTest( (functPointName), cp ); 

    delete cp;
    return (0);
}


Bruce Eckel: expandable sequence. Almost an array
#include <cstddef>
#include <iostream>
using namespace std;
 
template<class T>
class Array { // A simple, expandable sequence
  enum { INIT = 10 };
  T* data;
  size_t capacity;
  size_t count;
public:
  Array() {
    count = 0;
    data = new T[capacity = INIT];
  }
  ~Array() { delete [] data; }
  void push_back(const T& t) {
    if(count == capacity) {
      // Grow underlying array. 
      size_t newCap = 2 * capacity;
      T* newData = new T[newCap];
      // copy existing data to a bigger, newer buffer. Not very efficient CPU cycle wise.  
      for(size_t i = 0; i < count; ++i)
        newData[i] = data[i];
      delete [] data;
      data = newData;
      capacity = newCap;
    }
    data[count++] = t;
  }
  void pop_back() {
    if(count > 0)
      --count;
  }
  T* begin() { return data; }
  T* end() { return data + count; }
};
 
template<class T, template<class> class Seq>
class Container {
  Seq<T> seq;
public:
  void append(const T& t) { seq.push_back(t); }
  T* begin() { return seq.begin(); }
  T* end() { return seq.end(); }
};
 
int main() {
  Container<int, Array> container;
  container.append(1);
  container.append(2);
  int* p = container.begin();
  while(p != container.end())
    cout << *p++ << endl;
} ///:~
 
Online References
Home of[Thinking in C++ 2nd Edition by Bruce Eckel] Bruce Eckel text [Thinking in C++ 2nd Edition by Bruce Eckel]
[Unified Extensible Firmware Interface] [Benefits of EFI with Microsoft Benefits of EFI with Microsoft and Other Operating Systems and Other Operating Systems (Intel)]
[Imperfect C++ by Matthew Wilson]
  • RAII See as well
  • Portable vtables (GCC, Solaris, Linux, Visual C++, Borland WIN32)
  • ABI (Application Binary Interface not standardized - Static Libraries incompatible: -
    Compiler Using Library
    Borland CodeWarrior Digital Mars GCC Intel Visual C++
    Borland+--- -
    CodeWarrior-+-- -
    Digital Mars--+- -
    GCC-+-+ +
    Intel-+-+ +
    Visual C++-+-+ +
  • DLL; Borland prefixes with underscore, remaining compilers do not. GCC has another convention for name mangling



Feedback:


Ajax, Java and PHP snippets.

[Ajax ] [Java IE ] [Java IE ]

Integration Notes

[Machine Vision, Illumination] [Java, J2EE][LabVIEW ] [ORACLE ] [C++ ] [C#] [Aspect-Oriented Programming] [Embedded] [XP Agile CI]

[ CAN 2.0 (Bosch basic specification) ]