Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

RMI for C++

, 6 Aug 2009 CPOL
User-friendly remote method invocation in C++.
rcf.zip
RCF
demo
vs2003
RCF
Client
Server
doc
include
RCF
Connection.inl
Marshal.inl
Multiplexer.inl
RCF.inl
RcfServer.inl
ServerStub.inl
Protocol
util
Platform
Compiler
bcc55
cw80
gcc32
icl70
msvc71
Library
bcc55
cw80
gcc32
msvc60
msvc71
Machine
SPARC
x86
OS
Cygwin
Unix
Windows
System
NonWindows
Windows
Threads
SF
src
RCF
Protocol
util
SF
test
Jamfile
Jamrules
borland
Jamfile
Jamrules
vs2003
RCF
RCF
RCFTest
//*****************************************************************************
// Copyright (c) 2003. All rights reserved.
// Developed by Jarl Lindrud.
// Contact: jlindrud@hotmail.com .
//*****************************************************************************

//*****************************
// DEPRECATED!!!
//*****************************

#ifndef _UTIL_AUTORUN_HPP_
#define _UTIL_AUTORUN_HPP_

#define AUTO_RUN(func)                                _AUTO_RUN(func,  __LINE__) 
#define _AUTO_RUN(func, nID)                        __AUTO_RUN(func, nID)
#define __AUTO_RUN(func, nID)                        ___AUTO_RUN(func, nID)
#define ___AUTO_RUN(func, ID)                                                           \
    namespace {                                                                                  \
        struct AutoRun##ID {                                                                  \
            AutoRun##ID() {                                                                      \
                func;                                                                                 \
            }                                                                                           \
        } AutoRunInst##ID;                                                                     \
    }

    // More concise to implement AUTO_RUN using the following, but BCB emits an ICE on it.
    //static bool AutoRun##ID = ( func , false);


#define AUTO_RUN_1(func)                            AUTO_RUN_NAMED(func, 1)                    
#define AUTO_RUN_2(func)                            AUTO_RUN_NAMED(func, 2)                    
#define AUTO_RUN_3(func)                            AUTO_RUN_NAMED(func, 3)                    
#define AUTO_RUN_4(func)                            AUTO_RUN_NAMED(func, 4)                    
#define AUTO_RUN_5(func)                            AUTO_RUN_NAMED(func, 5)                    

#define AUTO_RUN_NAMED(func, name)                    _AUTO_RUN_NAMED(func, name, __LINE__) 
#define _AUTO_RUN_NAMED(func, name, nID)            __AUTO_RUN_NAMED(func, name, nID)
#define __AUTO_RUN_NAMED(func, name, nID)            ___AUTO_RUN(func, _##name##_##nID)

#define AUTO_RUN_ONCE(func)                            _AUTO_RUN_ONCE(func,  __LINE__) 
#define _AUTO_RUN_ONCE(func, nID)                    __AUTO_RUN_ONCE(func, nID)
#define __AUTO_RUN_ONCE(func, nID)                    ___AUTO_RUN_ONCE(func, nID)
#define ___AUTO_RUN_ONCE(func, ID)                                                         \
    struct AutoRunOnce##ID {                                                                      \
        AutoRunOnce##ID() {                                                                          \
            if (!init()) {                                                                                     \
                init() = true;                                                                              \
                func;                                                                                         \
            }                                                                                                   \
        }                                                                                                       \
        static bool &init() {                                                                            \
            static bool bInit = false;                                                                 \
            return bInit;                                                                                  \
        }                                                                                                       \
    };                                                                                                          \
    static AutoRunOnce##ID AutoRunOnceInst##ID;

#define AUTO_RUN_ONCE_1(func)                            AUTO_RUN_ONCE_NAMED(func, 1)                    
#define AUTO_RUN_ONCE_2(func)                            AUTO_RUN_ONCE_NAMED(func, 2)                    
#define AUTO_RUN_ONCE_3(func)                            AUTO_RUN_ONCE_NAMED(func, 3)                    
#define AUTO_RUN_ONCE_4(func)                            AUTO_RUN_ONCE_NAMED(func, 4)                    
#define AUTO_RUN_ONCE_5(func)                            AUTO_RUN_ONCE_NAMED(func, 5)                    

#define AUTO_RUN_ONCE_NAMED(func, name)                    _AUTO_RUN_ONCE_NAMED(func, name, __LINE__) 
#define _AUTO_RUN_ONCE_NAMED(func, name, nID)            __AUTO_RUN_ONCE_NAMED(func, name, nID)
#define __AUTO_RUN_ONCE_NAMED(func, name, nID)            ___AUTO_RUN_ONCE(func, _##name##_##nID)

#endif // ! _UTIL_AUTORUN_HPP_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Jarl Lindrud

Australia Australia
Software developer, ex-resident of Sweden and now living in Canberra, Australia, working on distributed C++ applications. Jarl enjoys programming, but prefers skiing and playing table tennis. He derives immense satisfaction from referring to himself in third person.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 6 Aug 2009
Article Copyright 2005 by Jarl Lindrud
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid