fix for linux?

This commit is contained in:
Daniel Larimer 2012-12-30 15:23:00 -08:00
commit 533dd28d67
7 changed files with 55 additions and 12 deletions

View file

@ -40,6 +40,7 @@ endif()
option( UNITY_BUILD OFF ) option( UNITY_BUILD OFF )
FIND_PACKAGE( OpenSSL ) FIND_PACKAGE( OpenSSL )
#FIND_PACKAGE( ZLIB )
include_directories( vendor/zlib-1.2.7/) include_directories( vendor/zlib-1.2.7/)
include_directories( vendor/libssh2-1.4.2/include ) include_directories( vendor/libssh2-1.4.2/include )
@ -98,7 +99,7 @@ add_subdirectory(vendor)
setup_library( fc SOURCES ${sources} ) setup_library( fc SOURCES ${sources} )
#setup_executable( json_rpc_test SOURCES tests/json_rpc_test.cpp LIBRARIES fc ${pthread_library} ${rt_library} ${Boost_THREAD_LIBRARY} ${Boost_CONTEXT_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${rt_library} ${Boost_DATE_TIME_LIBRARY}) #setup_executable( json_rpc_test SOURCES tests/json_rpc_test.cpp LIBRARIES fc ${ZLIB_LIBRARY} ${pthread_library} ${rt_library} ${Boost_THREAD_LIBRARY} ${Boost_CONTEXT_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${rt_library} ${Boost_DATE_TIME_LIBRARY})
#setup_executable( ssh_test SOURCES tests/ssh.cpp LIBRARIES fc ${pthread_library} ${rt_library} ${Boost_THREAD_LIBRARY} ${Boost_CONTEXT_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${rt_library} ssh2 ${OPENSSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${ZLIB_LIBRARY} ${ALL_OPENSSL_LIBRARIES} ${Boost_DATE_TIME_LIBRARY}) #setup_executable( ssh_test SOURCES tests/ssh.cpp LIBRARIES fc ${pthread_library} ${rt_library} ${Boost_THREAD_LIBRARY} ${Boost_CONTEXT_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${rt_library} ssh2 ${OPENSSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${ZLIB_LIBRARY} ${ALL_OPENSSL_LIBRARIES} ${Boost_DATE_TIME_LIBRARY})
#add_executable( test_vec tests/vector_test.cpp ) #add_executable( test_vec tests/vector_test.cpp )

View file

@ -1,5 +1,4 @@
#ifndef _FC_INTERPROCESS_FILEMAPPING_HPP_ #pragma once
#define _FC_INTERPROCESS_FILEMAPPING_HPP_
#include <fc/fwd.hpp> #include <fc/fwd.hpp>
#include <fc/utility.hpp> #include <fc/utility.hpp>
@ -35,4 +34,3 @@ namespace fc {
fc::fwd<boost::interprocess::mapped_region,40> my; fc::fwd<boost::interprocess::mapped_region,40> my;
}; };
} }
#endif

48
include/fc/signal.hpp Normal file
View file

@ -0,0 +1,48 @@
#pragma once
#include <fc/vector.hpp>
#include <functional>
namespace fc {
template<typename Signature>
class signal {
public:
typedef int64_t connection_id_type;
template<typename Functor>
connection_id_type connect( Functor&& f ) {
auto c = new std::function<Signature>( fc::forward<Functor>(f) );
_handlers.push_back( c );
return reinterpret_cast<connection_id_type>(c);
}
template<typename... Args>
void emit( Args&&... args ) {
for( size_t i = 0; i < _handlers.size(); ++i ) {
(*_handlers[i])( args... );
}
}
template<typename... Args>
void operator()( Args&&... args ) {
for( size_t i = 0; i < _handlers.size(); ++i ) {
(*_handlers[i])( args... );
}
}
void disconnect( connection_id_type cid ) {
auto itr = _handlers.begin();
while( itr != _handlers.end() ) {
if( reinterpret_cast<connection_id_type>(*itr) == cid ) {
delete *itr;
_handlers.erase(itr);
}
++itr;
}
}
private:
fc::vector< std::function<Signature>* > _handlers;
};
}

View file

@ -1,5 +1,3 @@
#ifndef _FC_SIGNALS_HPP
#define _FC_SIGNALS_HPP
#include <boost/signal.hpp> #include <boost/signal.hpp>
#include <fc/future.hpp> #include <fc/future.hpp>
#include <fc/thread.hpp> #include <fc/thread.hpp>
@ -27,4 +25,3 @@ namespace fc {
} }
} }
#endif

View file

@ -1,6 +1,3 @@
#ifndef _FC_SPIN_LOCK_HPP_
#define _FC_SPIN_LOCK_HPP_
namespace boost { namespace boost {
template<typename T> class atomic; template<typename T> class atomic;
} }
@ -38,4 +35,3 @@ namespace fc {
} // namespace fc } // namespace fc
#endif // _FC_SPIN_LOCK_HPP_

View file

@ -13,6 +13,9 @@ namespace fc {
return boost::lexical_cast<uint64_t>(s.c_str()); return boost::lexical_cast<uint64_t>(s.c_str());
} }
fc::string to_string( double d ){ return boost::lexical_cast<std::string>(d); } fc::string to_string( double d ){ return boost::lexical_cast<std::string>(d); }
#ifdef __APPLE__
fc::string to_string( size_t d ){ return boost::lexical_cast<std::string>(d); }
#endif
fc::string to_string( uint64_t d ){ return boost::lexical_cast<std::string>(d); } fc::string to_string( uint64_t d ){ return boost::lexical_cast<std::string>(d); }
fc::string to_string( uint32_t d ){ return boost::lexical_cast<std::string>(d); } fc::string to_string( uint32_t d ){ return boost::lexical_cast<std::string>(d); }
fc::string to_string( uint16_t d ){ return boost::lexical_cast<std::string>(d); } fc::string to_string( uint16_t d ){ return boost::lexical_cast<std::string>(d); }

View file

@ -1,3 +1,3 @@
add_subdirectory( libssh2-1.4.2 ) add_subdirectory( libssh2-1.4.2 )
add_subdirectory( zlib-1.2.7) add_subdirectory( zlib-1.2.7)
add_subdirectory( sigar ) #add_subdirectory( sigar )